Config: ClusterCache

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
 
Line 84: Line 84:
 
| style="white-space:nowrap" | cache-reader-writer
 
| style="white-space:nowrap" | cache-reader-writer
 
| Sets the CacheLoader and CacheWriter which the Cache can then use to populate cache misses from a reference store (database)
 
| Sets the CacheLoader and CacheWriter which the Cache can then use to populate cache misses from a reference store (database)
| javax.cache.CacheLoader, javax.cache.CacheWriter
+
| An object that implements both javax.cache.CacheLoader and javax.cache.CacheWriter
 
| Null
 
| Null
 
|-
 
|-

Latest revision as of 03:34, 18 October 2013

Gears-48.pngSquirrel-48.png

Contents

[edit] ClusterCache

A cache which stores consistent copies on the cluster segment.

Using the cache is like using java.util.Map. To add a new entry, call cache.put(key, value). To get the entry, call cache.get(key).

The cache configuration affects the lifetime, local caching timeouts and consistency.

ClusterCache is a javax.cache.Cache (JSR 107: JCache)

[edit] Example resin-web.xml

<web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin" xmlns:ee="urn:java:ee">

  <resin:ClusterCache ee:Named="myCache">
    <name>myCache</name>
    <modified-expire-timeout>1h</modified-expire-timeout>
  </resin:ClusterCache>

  ...

</web-app>

ee:Named makes the cache available for injection by name

[edit] Example code using CDI Injection

import javax.inject.*;
import javax.cache.*;

public class MyService {
 @Inject 
 @Named("myCache")
 private Cache<String,String> _cache;

 ...
}

[edit] <resin:ClusterCache> Attributes

[edit] Period Format

Personal tools
TOOLBOX
LANGUAGES