<web-app xmlns="http://caucho.com/ns/resin"
xmlns:ee="urn:java:ee"
xmlns:resin="urn:java:com.caucho.resin">
<resin:LocalCache ee:Named="my-cache">
<name>my-cache</name>
</resin:LocalCache>
</web-app>
import javax.inject.Inject;
import javax.cache.Cache;
public class MyService {
@Inject @Named("my-cache")
private Cache<String,String> _cache;
public String doStuff(String key)
{
String cachedValue = _cache.get(key);
if (cachedValue == null) {
cachedValue = doLongCalculation(key);
_cache.put(key, cachedValue);
}
return cachedValue;
}
}