Class GemfireCache
java.lang.Object
org.springframework.data.gemfire.cache.GemfireCache
- All Implemented Interfaces:
Cache
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
Cache.ValueRetrievalException, Cache.ValueWrapper -
Constructor Summary
ConstructorsConstructorDescriptionGemfireCache(Region<?, ?> region) Constructs an instance ofGemFireCacheinitialized with the given GemFireRegion. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the entire contents of this SpringCache.voidEvicts (destroys) the entry (key/value) mapped to the given key from this SpringCache.Returns the cache value for the given key wrapped in an instance ofCache.ValueWrapper.<T> TReturns the cache value for the given key cast to the specifiedClasstype.<T> TReturns the cache value for given key.getName()Returns the name of this SpringCache.voidStores the given value in the cache referenced by the given key.putIfAbsent(Object key, Object value) Implementation ofCache.putIfAbsent(Object, Object)satisfying the extension of theCacheinterface in Spring 4.1.static GemfireCacheWraps a GemFireRegionin an instance ofGemfireCacheto adapt the GemFireRegionto function as a SpringCachein Spring's caching infrastructure.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.cache.Cache
evictIfPresent, invalidate
-
Constructor Details
-
GemfireCache
Constructs an instance ofGemFireCacheinitialized with the given GemFireRegion. TheRegionwill function as the backing store and implementation for the SpringCacheinterface.- Parameters:
region- GemFireRegionbacking the SpringCache.- Throws:
IllegalArgumentException- ifRegionis null.
-
-
Method Details
-
wrap
Wraps a GemFireRegionin an instance ofGemfireCacheto adapt the GemFireRegionto function as a SpringCachein Spring's caching infrastructure.- Parameters:
region- GemFireRegionto wrap.- Returns:
- an instance of
GemfireCachebacked by the provided GemFireRegion. - See Also:
-
getNativeCache
- Specified by:
getNativeCachein interfaceCache- Returns:
- the GemFire
Regionused as the implementation for this SpringCache. - See Also:
-
getName
Returns the name of this SpringCache. -
clear
public void clear()Clears the entire contents of this SpringCache. -
evict
Evicts (destroys) the entry (key/value) mapped to the given key from this SpringCache. -
get
Returns the cache value for the given key wrapped in an instance ofCache.ValueWrapper. -
get
Returns the cache value for the given key cast to the specifiedClasstype.- Specified by:
getin interfaceCache- Type Parameters:
T- desiredClasstype of the cache value.- Parameters:
key- key identifying the the value to retrieve from the cache.type- desiredClasstype of the value.- Returns:
- the cache value for the given key cast to the specified
Classtype. - Throws:
IllegalStateException- if the value is not null and not an instance of the desired type.- See Also:
-
get
Returns the cache value for given key. If the value is null, then the providedCallablevalueLoaderwill be called to obtain a value and add the entry to this cache.- Specified by:
getin interfaceCache- Type Parameters:
T-Classtype of the value.- Parameters:
key- key identifying the the value to retrieve from the cache.valueLoader-Callableobject used to load a value if the entry identified by the key does not already have value.- Returns:
- the cache value of the given key or a value obtained by calling the
Callableobject if the value for key is null. - Throws:
Cache.ValueRetrievalException- if an error occurs while trying to load a value for given key using theCallable.- See Also:
-
put
Stores the given value in the cache referenced by the given key. This operation will only store the value if the value is not null. -
putIfAbsent
Implementation ofCache.putIfAbsent(Object, Object)satisfying the extension of theCacheinterface in Spring 4.1. Don't add theOverrideannotation otherwise this will break the compilation on 4.0.- Specified by:
putIfAbsentin interfaceCache- Returns:
- the existing value if the given key is already mapped to a value.
- See Also:
-