Config: ClusterCache

From Resin 4.0 Wiki

(Difference between revisions)
Jump to: navigation, search
Line 21: Line 21:
 
   
 
   
 
  </web-app>
 
  </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 ==
 
== <resin:ClusterCache> Attributes ==

Revision as of 03:26, 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