This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" | |
<!-- Line 4 --> maxBytesLocalHeap="50%"> | |
<diskStore path="java.io.tmpdir/EhCacheSpringExample1" /> | |
<cache name="weatherCache" statistics="true" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Copyright 2011 Nicholas Blair, Eric Dalquist | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Go from this | |
<ehcache> | |
// to this | |
<ehcache maxBytesLocalHeap="100M" > | |
// or | |
<ehcache maxBytesLocalHeap="50%" > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Collection getAllAlbumsBy(Artist artist){ | |
List results = new ArrayList(); | |
for(Iterator i = getAllAlbums();i.hasNext();){ | |
Album album = (Album)i.next(); | |
if(album.isBy(artist)){ | |
results.add(album); | |
} | |
} | |
return results; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
albums = getAllAlbumsBy(artist); | |
songs = getAllSongs(artist); | |
printSongCountHeader(songs.size()); | |
pringAlbumCountHeader(albums.size()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configuration config; | |
FactoryConfiguration factoryConfig = new FactoryConfiguration(); | |
factoryConfig.setClass("org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory"); | |
factoryConfig.setProperties("monitorAddress=localhost, monitorPort=9889"); | |
config.addCacheManagerPeerListenerFactory(factoryConfig); | |
... and in pom.xml: | |
<dependency> | |
<groupId>org.terracotta</groupId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Query query = cache.createQuery(); | |
query.includeKeys(); | |
query.includeValues(); | |
query.addCriteria(name.ilike(“Greg*”).and(gender.eq(Gender.MALE))).addOrderBy(age, Direction.ASCENDING).maxResults(10); | |
Results results = query.execute(); | |
System.out.println(” Size: ” + results.size()); | |
for (Result result : results.all()) { | |
System.out.println(“Got: Key[" + result.getKey() + "] Value class [" + result.getValue().getClass() + "] Value [" + result.getValue() + "]“); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<repositories> | |
<repository> | |
<id>terracotta-snapshots</id> | |
<name>Terracotta Repo</name> | |
<url>http://www.terracotta.org/download/reflector/releases</url> | |
</repository> | |
</repositories> | |
<pluginRepositories> | |
<pluginRepository> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Quartz 1.8.4 Example 3 snippet | |
// job 7 will run every 30 seconds but only on Weekends (Saturday and | |
// Sunday) | |
job = new JobDetail("job7", "group1", SimpleJob.class); | |
trigger = new CronTrigger("trigger7", "group1", "job7", "group1", | |
"0,30 * * ? * SAT,SUN"); | |
sched.addJob(job, true); | |
ft = sched.scheduleJob(trigger); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Quartz scheduler Example 2 from 1.8.3 | |
// job3 will run 11 times (run once and repeat 10 more times) | |
// job3 will repeat every 10 seconds (10000 ms) | |
job = new JobDetail("job3", "group1", SimpleJob.class); | |
trigger = new SimpleTrigger("trigger3", "group1", "job3", "group1", | |
new Date(ts), null, 10, 10000L); | |
ft = sched.scheduleJob(job, trigger); | |
// the same job (job3) will be scheduled by a another trigger |
NewerOlder