Class AerospikeCache
java.lang.Object
org.springframework.data.aerospike.cache.AerospikeCache
- All Implemented Interfaces:
Cache
A Cache
Cache implementation backed by Aerospike database as store. Create and
configure Aerospike cache instances via AerospikeCacheManager.- Author:
- Venil Noronha
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
Cache.ValueRetrievalException, Cache.ValueWrapper -
Constructor Summary
ConstructorsConstructorDescriptionAerospikeCache(String name, com.aerospike.client.IAerospikeClient client, AerospikeConverter aerospikeConverter, AerospikeCacheConfiguration cacheConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the cache by truncating the configured cache's set (in the configured namespace).voidDeletes the key from Aerospike database.Returns the value (bins) from the Aerospike database to which this cache maps the specified key.<T> TReturn the value (bins) from the Aerospike database to which this cache maps the specified key.<T> TReturn the value (bins) from the Aerospike database to which this cache maps the specified key, obtaining that value from valueLoader if necessary.getName()Get cache's name.Get the underlying native cache provider - the Aerospike client.voidWrite the key-value pair to Aerospike database.putIfAbsent(Object key, Object value) Write the key-value pair to Aerospike database if the key doesn't already exist.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.cache.Cache
evictIfPresent, invalidate, retrieve, retrieve
-
Constructor Details
-
AerospikeCache
public AerospikeCache(String name, com.aerospike.client.IAerospikeClient client, AerospikeConverter aerospikeConverter, AerospikeCacheConfiguration cacheConfiguration)
-
-
Method Details
-
clear
public void clear()Clears the cache by truncating the configured cache's set (in the configured namespace). -
evict
Deletes the key from Aerospike database. -
getName
Get cache's name. -
getNativeCache
Get the underlying native cache provider - the Aerospike client.- Specified by:
getNativeCachein interfaceCache- Returns:
- The aerospike client.
-
get
Return the value (bins) from the Aerospike database to which this cache maps the specified key, obtaining that value from valueLoader if necessary. This method provides a simple substitute for the conventional "if cached, return; otherwise create, cache and return" pattern. -
get
Return the value (bins) from the Aerospike database to which this cache maps the specified key. Generically specifying a type that return value will be cast to.- Specified by:
getin interfaceCache- Parameters:
key- The key whose associated value (bins) is to be returned.type- The required type of the returned value (can be null to bypass a type check; in case of a null value found in the cache, the specified type is irrelevant).- Returns:
- The value (bins) to which this cache maps the specified key (which may be null itself), or also null if the cache contains no mapping for this key.
-
get
Returns the value (bins) from the Aerospike database to which this cache maps the specified key. Returns null if the cache contains no mapping for this key; otherwise, the cached value (which may be null itself) will be returned in a Cache.ValueWrapper.- Specified by:
getin interfaceCache- Parameters:
key- The key whose associated value (bins) is to be returned.- Returns:
- The value (bins) to which this cache maps the specified key, contained within a Cache.ValueWrapper which may also hold a cached null value. A straight null being returned means that the cache contains no mapping for this key.
-
put
Write the key-value pair to Aerospike database. -
putIfAbsent
Write the key-value pair to Aerospike database if the key doesn't already exist.- Specified by:
putIfAbsentin interfaceCache- Parameters:
key- The key to write.value- The value (bins) to write.- Returns:
- In case the key already exists return the existing value, else return null.
-