Spring Data for VMware GemFire
Class GemfireCache
java.lang.Object
org.springframework.data.gemfire.cache.GemfireCache
- All Implemented Interfaces:
org.springframework.cache.Cache
Spring Framework
Cache implementation backed by a GemFire Region.- See Also:
-
CacheRegion
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
org.springframework.cache.Cache.ValueRetrievalException, org.springframework.cache.Cache.ValueWrapper -
Constructor Summary
ConstructorsConstructorDescriptionGemfireCache(org.apache.geode.cache.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.org.springframework.cache.Cache.ValueWrapperReturns 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.org.apache.geode.cache.RegionReturns the GemFireRegionused as the implementation for this SpringCache.voidStores the given value in the cache referenced by the given key.org.springframework.cache.Cache.ValueWrapperputIfAbsent(Object key, Object value) Implementation ofCache.putIfAbsent(Object, Object)satisfying the extension of theCacheinterface in Spring 4.1.static GemfireCachewrap(org.apache.geode.cache.Region<?, ?> region) Wraps 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
public GemfireCache(org.apache.geode.cache.Region<?, ?> region) 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:
-
RegionCacheGemfireCache(Region)
-
getNativeCache
public org.apache.geode.cache.Region getNativeCache()Returns the GemFireRegionused as the implementation for this SpringCache.- Specified by:
getNativeCachein interfaceorg.springframework.cache.Cache- Returns:
- the GemFire
Regionused as the implementation for this SpringCache. - See Also:
-
Region
-
getName
Returns the name of this SpringCache.- Specified by:
getNamein interfaceorg.springframework.cache.Cache- Returns:
- the name of this Spring
Cache. - See Also:
-
Region.getName()
-
clear
public void clear()Clears the entire contents of this SpringCache.- Specified by:
clearin interfaceorg.springframework.cache.Cache- See Also:
-
Region.clear()
-
evict
Evicts (destroys) the entry (key/value) mapped to the given key from this SpringCache.- Specified by:
evictin interfaceorg.springframework.cache.Cache- Parameters:
key- key used to identify the cache entry to evict.- See Also:
-
Region.destroy(Object)
-
get
Returns the cache value for the given key wrapped in an instance ofCache.ValueWrapper.- Specified by:
getin interfaceorg.springframework.cache.Cache- Parameters:
key- key identifying the the value to retrieve from the cache.- Returns:
- the value cached with the given key.
- See Also:
-
Cache.ValueWrapperRegion.get(Object)
-
get
Returns the cache value for the given key cast to the specifiedClasstype.- Specified by:
getin interfaceorg.springframework.cache.Cache- 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:
-
Region.get(Object)
-
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 interfaceorg.springframework.cache.Cache- 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:
org.springframework.cache.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.- Specified by:
putin interfaceorg.springframework.cache.Cache- Parameters:
key- key used to reference the value in the cache.value- value to store in the cache referenced by the key.- See Also:
-
Region.put(Object, Object)
-
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 interfaceorg.springframework.cache.Cache- Returns:
- the existing value if the given key is already mapped to a value.
- See Also:
-
Cache.putIfAbsent(Object, Object)Region.putIfAbsent(Object, Object)
-