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 void
clear()
May work async.void
evict(Object key)
May work async.boolean
evictIfPresent(Object key)
Returns when evicted.@Nullable org.springframework.cache.Cache.ValueWrapper
get(Object key)
Get value from the cache, may invoke the loader if one is specified.<T> T
get(Object key, @Nullable Class<T> type)
<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=true
is specified on theCacheable
annotation.String
getName()
org.cache2k.Cache<Object,Object>
getNativeCache()
boolean
invalidate()
Like clear, but returns when everything is cleared.boolean
isLoaderPresent()
void
put(Object key, Object value)
org.springframework.cache.Cache.ValueWrapper
putIfAbsent(Object key, Object value)
-
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.springframework.cache.Cache
-
getNativeCache
public org.cache2k.Cache<Object,Object> getNativeCache()
- Specified by:
getNativeCache
in 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:
get
in interfaceorg.springframework.cache.Cache
-
get
public <T> T get(Object key, @Nullable @Nullable Class<T> type)
- Specified by:
get
in 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=true
is specified on theCacheable
annotation.- Specified by:
get
in interfaceorg.springframework.cache.Cache
-
put
public void put(Object key, Object value)
- Specified by:
put
in interfaceorg.springframework.cache.Cache
-
putIfAbsent
public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, Object value)
- Specified by:
putIfAbsent
in interfaceorg.springframework.cache.Cache
-
evict
public void evict(Object key)
May work async.- Specified by:
evict
in interfaceorg.springframework.cache.Cache
-
clear
public void clear()
May work async.- Specified by:
clear
in interfaceorg.springframework.cache.Cache
-
evictIfPresent
public boolean evictIfPresent(Object key)
Returns when evicted.- Specified by:
evictIfPresent
in interfaceorg.springframework.cache.Cache
-
invalidate
public boolean invalidate()
Like clear, but returns when everything is cleared.- Specified by:
invalidate
in interfaceorg.springframework.cache.Cache
-
isLoaderPresent
public boolean isLoaderPresent()
-
-