Package org.cache2k.extra.spring
Class SpringCache2kCache
- java.lang.Object
-
- org.cache2k.extra.spring.SpringCache2kCache
-
- All Implemented Interfaces:
org.springframework.cache.Cache
public class SpringCache2kCache extends Object implements org.springframework.cache.Cache
Cache wrapper for the spring cache abstraction.- Author:
- Jens Wilke
-
-
Constructor Summary
Constructors Constructor Description SpringCache2kCache(org.cache2k.Cache<Object,Object> cache)Create an adapter instance for the given cache2k instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()May work async.voidevict(Object key)May work async.booleanevictIfPresent(Object key)Returns when evicted.@Nullable org.springframework.cache.Cache.ValueWrapperget(Object key)Get value from the cache, may invoke the loader if one is specified.<T> Tget(Object key, @Nullable Class<T> type)<T> Tget(Object key, Callable<T> valueLoader)This method is called instead ofget(java.lang.Object)andput(java.lang.Object, java.lang.Object)in casesync=trueis specified on theCacheableannotation.StringgetName()org.cache2k.Cache<Object,Object>getNativeCache()booleaninvalidate()Like clear, but returns when everything is cleared.booleanisLoaderPresent()voidput(Object key, Object value)org.springframework.cache.Cache.ValueWrapperputIfAbsent(Object key, Object value)
-
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getNamein interfaceorg.springframework.cache.Cache
-
getNativeCache
public org.cache2k.Cache<Object,Object> getNativeCache()
- Specified by:
getNativeCachein interfaceorg.springframework.cache.Cache
-
get
@Nullable public @Nullable org.springframework.cache.Cache.ValueWrapper get(Object key)
Get value from the cache, may invoke the loader if one is specified. the get() method is used by Spring if the sync parameter is not set.- Specified by:
getin interfaceorg.springframework.cache.Cache
-
get
public <T> T get(Object key, @Nullable @Nullable Class<T> type)
- Specified by:
getin interfaceorg.springframework.cache.Cache
-
get
public <T> T get(Object key, Callable<T> valueLoader)
This method is called instead ofget(java.lang.Object)andput(java.lang.Object, java.lang.Object)in casesync=trueis specified on theCacheableannotation.- Specified by:
getin interfaceorg.springframework.cache.Cache
-
put
public void put(Object key, Object value)
- Specified by:
putin interfaceorg.springframework.cache.Cache
-
putIfAbsent
public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, Object value)
- Specified by:
putIfAbsentin interfaceorg.springframework.cache.Cache
-
evict
public void evict(Object key)
May work async.- Specified by:
evictin interfaceorg.springframework.cache.Cache
-
clear
public void clear()
May work async.- Specified by:
clearin interfaceorg.springframework.cache.Cache
-
evictIfPresent
public boolean evictIfPresent(Object key)
Returns when evicted.- Specified by:
evictIfPresentin interfaceorg.springframework.cache.Cache
-
invalidate
public boolean invalidate()
Like clear, but returns when everything is cleared.- Specified by:
invalidatein interfaceorg.springframework.cache.Cache
-
isLoaderPresent
public boolean isLoaderPresent()
-
-