Config: ClusterCache
From Resin 4.0 Wiki
(Difference between revisions)
(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 | + | | 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 | + | | TRANSIENT or LOCAL or CLUSTER |
| CLUSTER | | CLUSTER | ||
|- | |- |
Latest revision as of 03:34, 18 October 2013
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
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) | An object that implements both javax.cache.CacheLoader and 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 |
[edit] Period Format
ms | milliseconds |
s | seconds |
m | minutes |
h | hours |
D | days |
W | weeks |
M | months |
Y | years |