Config: ClusterCache
From Resin 4.0 Wiki
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
Name | Description | Type | Default |
---|---|---|---|
name | A name is mandatory and must be unique among open caches | String | required |
manager-name | String | Null | |
cache-loader | CacheLoader that the Cache can then use to populate cache misses from a reference store (database) | javax.cache.CacheLoader | Null |
read-through | Use CacheLoader | Boolean | False |
read-through-expire-timeout | Period | Infinity | |
cache-writer | CacheWrite that the Cache can then use to save cache misses from a reference store (database) | javax.cache.CacheWriter | Null |
write-through | Use CacheWriter | Boolean | False |
cache-reader-writer | 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 | Null |
serializer | Assign the serializer used on values. (This setting should not be changed after a cache is created) | com.caucho.distcache.CacheSerializer | Null |
accessed-expire-timeout | The maximum idle time for an item, which is typically used for temporary data like sessions. For example, session data might be removed if idle over 30 minutes. Cached data would have infinite idle time because it doesn't depend on how often it's accessed. | Period | Infinity |
idle-timeout | Deprecated - use accessed-expire-timeout | Period | Infinity |
accessed-expire-timeout-window | Idle check window, used to minimize traffic when updating access times | Period | accessed-expire-timeout / 4 |
modified-expire-timeout | The maximum valid time for an item. Items stored in the cache for longer than the expire time are no longer valid and will return null from a get | Period | Infinity |
lease-expire-timeout | The lease timeout is the time a server can use the local version if it owns it, before a timeout | Period | 5m |
local-expire-timeout | The local read timeout is how long a local copy of a cache item can be reused before checking with the master copy. A read-only item could be infinite (-1). A slow changing item like a list of bulletin-board comments could be 10s. Even a relatively quickly changing item can be 10ms or 100ms. | Period | 250ms |
local-read-timeout | Deprecated - use local-expire-timeout | Period | 250ms |
scope-model | TRANSIENT or LOCAL or CLUSTER | CLUSTER | |
backing | Same effect as cache-reader-writer | com.caucho.server.distcache.CacheBacking | Null |
Period Format
ms | milliseconds |
s | seconds |
m | minutes |
h | hours |
D | days |
W | weeks |
M | months |
Y | years |