public class SafeCacheWrapper extends Object implements org.springframework.cache.Cache
Safe cache wrapper which wraps a given cache and swallows the exception and logs the errors. If the error occurs in the put/evict/clear methods then it tries to clear the cache to avoid stale data in the cache.
Modifier and Type | Method and Description |
---|---|
void |
clear() |
static SafeCacheWrapper |
create(org.springframework.cache.Cache wrappedCache)
Creates a new instance based on the given
Cache . |
void |
evict(Object key) |
org.springframework.cache.Cache.ValueWrapper |
get(Object key) |
<T> T |
get(Object key,
Callable<T> valueLoader) |
<T> T |
get(Object key,
Class<T> type) |
String |
getName() |
Object |
getNativeCache() |
void |
put(Object key,
Object value) |
org.springframework.cache.Cache.ValueWrapper |
putIfAbsent(Object key,
Object value) |
public static SafeCacheWrapper create(org.springframework.cache.Cache wrappedCache)
Creates a new instance based on the given Cache
.
wrappedCache
- the cache for which to add the fallback mechanismpublic String getName()
getName
in interface org.springframework.cache.Cache
public Object getNativeCache()
getNativeCache
in interface org.springframework.cache.Cache
public org.springframework.cache.Cache.ValueWrapper get(Object key)
get
in interface org.springframework.cache.Cache
public <T> T get(Object key, Class<T> type)
get
in interface org.springframework.cache.Cache
public <T> T get(Object key, Callable<T> valueLoader)
get
in interface org.springframework.cache.Cache
public void put(Object key, Object value)
put
in interface org.springframework.cache.Cache
public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, Object value)
putIfAbsent
in interface org.springframework.cache.Cache
public void evict(Object key)
evict
in interface org.springframework.cache.Cache
public void clear()
clear
in interface org.springframework.cache.Cache
Copyright © 2010 - 2019 edorasware ag. All Rights Reserved.