JSR 107
Cache<String, Integer> cache = Caching.getCache("simpleCache", String.class, Integer.class);
13
JSR 107/** * Type of Expiry */public enum ExpiryType { /** * Time since last modified. Creation is also considered a modification event. */ MODIFIED, /** * Time since last <em>accessed</em>. Access means any access to an entry including * a modification event. Examples are: * <ul> * <li>put</li> * <li>get</li> * <li>containsKey</li> * <li>iteration</li> * </ul> * */ ACCESSED}
18
JSR 107
String helloMessage = cache.get("helloKey"); if (helloMessage == null) { helloMessage = new StringBuilder(20) .append("Hello World ! ") .append(System.currentTimeMillis()).toString(); cache.put("helloKey", helloMessage);}
• // functionnal use of the helloMessage
21
Cache as a s-o-r : Read through
Database
Application
Ehcache
Persistence layer
#CodeMotion @MathildeLemee
public interface CacheLoader<K, V> { /** * Loads an object. Application developers should implement this * method to customize the loading of a value for a cache entry. This method * is called by a cache when a requested entry is not in the cache. If * the object can't be loaded <code>null</code> should be returned. */ V load(K key) throws CacheLoaderException; /** * Loads multiple objects. Application developers should implement this * method to customize the loading of cache entries. This method is called * when the requested object is not in the cache. If an object can't be loaded, * it is not returned in the resulting map. */ Map<K, V> loadAll(Iterable<? extends K> keys) throws CacheLoaderException;}
24
Cache as a s-o-r : Write through
Database
Application
Ehcache
Persistence layer
#CodeMotion @MathildeLemee
public interface CacheWriter<K, V> {
void write(Cache.Entry<? extends K, ? CacheWriterException; void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) throws CacheWriterException; void delete(Object key) throws CacheWriterException; void deleteAll(Collection<?> keys) throws CacheWriterException; }
26
Cache as a s-o-r : Write Behind
Database
Application
Ehcache
Persistence layer
Write-behind thread
#CodeMotion @MathildeLemee
Configuration managerConfig = new Configuration() .terracotta(new TerracottaClientConfiguration().url("localhost:9510").rejoin(true)) .cache(new CacheConfiguration().name("nonstop-sample") .persistence(new PersistenceConfiguration().strategy(DISTRIBUTED)) .maxBytesLocalHeap(128, MemoryUnit.MEGABYTES) .maxBytesLocalOffHeap(1, MemoryUnit.GIGABYTES) .terracotta(new TerracottaConfiguration() ));
54
“Event processing is a method of tracking and analyzing (processing)
streams of information (data) about things that happen (events),[1] and deriving a
conclusion from them”#CodeMotion @MathildeLemee
Credit :
http://gridgain.blogspot.fr/2012/11/gridgain-and-hadoop-differences-and.html
http://www.infoq.com/articles/write-behind-caching
#CodeMotion @MathildeLemee
Top Related