Comme pour les caches d'unité d'exécution locale, vous ne devez accéder aux caches de transaction locale que lorsque le contexte approprié (transaction) existe.
public void myMethod() {
...
Cache<String, String> txnCache = CacheManagerEjb.
getTransactionLocalCacheGroup().getCache("mycache");
String value = txnCache.get("key");
if(value == null) {
// perform expensive operation to calculate value - this
// processing only happens once per transaction
...
// and store the result
txnCache.put("key", "value");
}
...
}