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:
-
Cache
Region
-
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
ConstructorDescriptionGemfireCache
(org.apache.geode.cache.Region<?, ?> region) Constructs an instance ofGemFireCache
initialized with the given GemFireRegion
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the entire contents of this SpringCache
.void
Evicts (destroys) the entry (key/value) mapped to the given key from this SpringCache
.org.springframework.cache.Cache.ValueWrapper
Returns the cache value for the given key wrapped in an instance ofCache.ValueWrapper
.<T> T
Returns the cache value for the given key cast to the specifiedClass
type.<T> T
Returns the cache value for given key.getName()
Returns the name of this SpringCache
.org.apache.geode.cache.Region
Returns the GemFireRegion
used as the implementation for this SpringCache
.void
Stores the given value in the cache referenced by the given key.org.springframework.cache.Cache.ValueWrapper
putIfAbsent
(Object key, Object value) Implementation ofCache.putIfAbsent(Object, Object)
satisfying the extension of theCache
interface in Spring 4.1.static GemfireCache
wrap
(org.apache.geode.cache.Region<?, ?> region) Wraps a GemFireRegion
in an instance ofGemfireCache
to adapt the GemFireRegion
to function as a SpringCache
in Spring's caching infrastructure.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.cache.Cache
evictIfPresent, invalidate
-
Constructor Details
-
GemfireCache
public GemfireCache(org.apache.geode.cache.Region<?, ?> region) Constructs an instance ofGemFireCache
initialized with the given GemFireRegion
. TheRegion
will function as the backing store and implementation for the SpringCache
interface.- Parameters:
region
- GemFireRegion
backing the SpringCache
.- Throws:
IllegalArgumentException
- ifRegion
is null.
-
-
Method Details
-
wrap
Wraps a GemFireRegion
in an instance ofGemfireCache
to adapt the GemFireRegion
to function as a SpringCache
in Spring's caching infrastructure.- Parameters:
region
- GemFireRegion
to wrap.- Returns:
- an instance of
GemfireCache
backed by the provided GemFireRegion
. - See Also:
-
Region
Cache
GemfireCache(Region)
-
getNativeCache
public org.apache.geode.cache.Region getNativeCache()Returns the GemFireRegion
used as the implementation for this SpringCache
.- Specified by:
getNativeCache
in interfaceorg.springframework.cache.Cache
- Returns:
- the GemFire
Region
used as the implementation for this SpringCache
. - See Also:
-
Region
-
getName
Returns the name of this SpringCache
.- Specified by:
getName
in 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:
clear
in 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:
evict
in 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:
get
in 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.ValueWrapper
Region.get(Object)
-
get
Returns the cache value for the given key cast to the specifiedClass
type.- Specified by:
get
in interfaceorg.springframework.cache.Cache
- Type Parameters:
T
- desiredClass
type of the cache value.- Parameters:
key
- key identifying the the value to retrieve from the cache.type
- desiredClass
type of the value.- Returns:
- the cache value for the given key cast to the specified
Class
type. - 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 providedCallable
valueLoader
will be called to obtain a value and add the entry to this cache.- Specified by:
get
in interfaceorg.springframework.cache.Cache
- Type Parameters:
T
-Class
type of the value.- Parameters:
key
- key identifying the the value to retrieve from the cache.valueLoader
-Callable
object 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
Callable
object 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:
put
in 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 theCache
interface in Spring 4.1. Don't add theOverride
annotation otherwise this will break the compilation on 4.0.- Specified by:
putIfAbsent
in 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)
-