Config: ClusterCache

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
 
(One intermediate revision by one user not shown)
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
 
|-
 
|-
Line 129: Line 129:
 
| style="white-space:nowrap" | scope-model
 
| style="white-space:nowrap" | scope-model
 
|  
 
|  
| TRANSIENT|LOCAL|CLUSTER
+
| TRANSIENT or LOCAL or CLUSTER
 
| CLUSTER
 
| CLUSTER
 
|-
 
|-

Latest revision as of 03:34, 18 October 2013

Gears-48.pngSquirrel-48.png

Contents

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)

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

Example code using CDI Injection

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

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

 ...
}

<resin:ClusterCache> Attributes

Period Format

Personal tools
TOOLBOX
LANGUAGES