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
ConstructorDescriptionGemfireCache
(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
.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
.void
Stores 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 theCache
interface in Spring 4.1.static GemfireCache
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
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:
-
getNativeCache
- Specified by:
getNativeCache
in interfaceCache
- Returns:
- the GemFire
Region
used 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 specifiedClass
type.- Specified by:
get
in interfaceCache
- 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:
-
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 interfaceCache
- 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:
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 theCache
interface in Spring 4.1. Don't add theOverride
annotation otherwise this will break the compilation on 4.0.- Specified by:
putIfAbsent
in interfaceCache
- Returns:
- the existing value if the given key is already mapped to a value.
- See Also:
-