Package org.cache2k.jcache.provider
Class TouchyJCacheAdapter<K,V>
- java.lang.Object
-
- org.cache2k.jcache.provider.TouchyJCacheAdapter<K,V>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<javax.cache.Cache.Entry<K,V>>
,javax.cache.Cache<K,V>
public class TouchyJCacheAdapter<K,V> extends Object implements javax.cache.Cache<K,V>
Adapter to add required semantics for JSR107 with a custom expiry policy. The JCacheAdapter is wrapped again and the expiry policy is called when needed.There are multiple requirements which makes cache operations with expiry policy very inefficient. These are:
- The TCK checks that the access policy is called and adjusted on each cache request
- The TCK has some tests that use a zero duration on expiry, so an entry is expired after the first access
- The TCK does not allow that the expiry policy methods are called in the configuration phase
- In case the expiry policy methods return null, this means, that the expiry is not changed
- Author:
- Jens Wilke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TouchyJCacheAdapter.ExpiryPolicyAdapter<K,V>
-
Constructor Summary
Constructors Constructor Description TouchyJCacheAdapter(JCacheAdapter<K,V> cache, javax.cache.expiry.ExpiryPolicy expiryPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
close()
boolean
containsKey(K key)
void
deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cfg)
V
get(K key)
Map<K,V>
getAll(Set<? extends K> keys)
V
getAndPut(K key, V value)
V
getAndRemove(K key)
V
getAndReplace(K key, V value)
javax.cache.CacheManager
getCacheManager()
<C extends javax.cache.configuration.Configuration<K,V>>
CgetConfiguration(Class<C> clazz)
String
getName()
<T> T
invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>>
invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)
boolean
isClosed()
Iterator<javax.cache.Cache.Entry<K,V>>
iterator()
void
loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
void
put(K key, V value)
void
putAll(Map<? extends K,? extends V> map)
boolean
putIfAbsent(K key, V value)
void
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cfg)
boolean
remove(K key)
boolean
remove(K key, V oldValue)
void
removeAll()
void
removeAll(Set<? extends K> keys)
boolean
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
String
toString()
<T> T
unwrap(Class<T> clazz)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
TouchyJCacheAdapter
public TouchyJCacheAdapter(JCacheAdapter<K,V> cache, javax.cache.expiry.ExpiryPolicy expiryPolicy)
-
-
Method Detail
-
containsKey
public boolean containsKey(K key)
-
loadAll
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
-
getConfiguration
public <C extends javax.cache.configuration.Configuration<K,V>> C getConfiguration(Class<C> clazz)
-
invoke
public <T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments) throws javax.cache.processor.EntryProcessorException
-
invokeAll
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)
-
getCacheManager
public javax.cache.CacheManager getCacheManager()
-
close
public void close()
-
unwrap
public <T> T unwrap(Class<T> clazz)
-
registerCacheEntryListener
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cfg)
-
deregisterCacheEntryListener
public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cfg)
-
-