Package org.nuxeo.ecm.core.cache
Interface Cache
-
- All Known Subinterfaces:
CacheManagement
- All Known Implementing Classes:
AbstractCache
,CacheAttributesChecker
,CacheInvalidator
,CacheMetrics
,CacheWrapper
,InMemoryCacheImpl
public interface Cache
The nuxeo cache interface that define generic methods to use cache technologies- Since:
- 6.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V extends Serializable>
VcomputeIfAbsent(String key, Supplier<V> supplier)
Retrieves the value from the cache and returns it.Serializable
get(String key)
Get method to retrieve value from cache Must not raise exception if the key is null, but return nullString
getName()
Get cache name as specified in the descriptordefault boolean
hasEntry(String key)
Check if a given key is present inside the cache.void
invalidate(String key)
Invalidate the given keyvoid
invalidateAll()
Invalidate all key-value stored in the cacheSet<String>
keySet()
Returns the set of all keys stored in the cache.void
put(String key, Serializable value)
Put method to store aSerializable
value
-
-
-
Method Detail
-
getName
String getName()
Get cache name as specified in the descriptor- Returns:
- the cache name
- Since:
- 6.0
-
get
Serializable get(String key)
Get method to retrieve value from cache Must not raise exception if the key is null, but return null- Parameters:
key
- the string key- Returns:
- the
Serializable
value, return null if the key does not exist or if the key is null - Since:
- 6.0
-
computeIfAbsent
default <V extends Serializable> V computeIfAbsent(String key, Supplier<V> supplier)
Retrieves the value from the cache and returns it. If the associated value is null, retrieves it from thesupplier
and put it into the cache.- Since:
- 11.5
- Implementation Note:
- The key must not be null
-
keySet
Set<String> keySet()
Returns the set of all keys stored in the cache.- Returns:
- the
Set
of all keys - Since:
- 8.3
-
invalidate
void invalidate(String key)
Invalidate the given key- Parameters:
key
- , the key to remove from the cache, if null will do nothing- Since:
- 6.0
-
invalidateAll
void invalidateAll()
Invalidate all key-value stored in the cache- Since:
- 6.0
-
put
void put(String key, Serializable value)
Put method to store aSerializable
value- Parameters:
key
- the string key, if null, the value will not be storedvalue
- the value to store, if null, the value will not be stored- Since:
- 6.0
-
hasEntry
default boolean hasEntry(String key)
Check if a given key is present inside the cache. Compared to the get() method, this method must not update internal cache state and change TTL- Parameters:
key
- the string key- Returns:
- true if a corresponding entry exists, false otherwise
- Since:
- 7.2
-
-