public class InMemoryCacheImpl extends AbstractCache
Modifier and Type | Field and Description |
---|---|
protected com.google.common.cache.Cache<String,Serializable> |
cache |
name, ttl
Constructor and Description |
---|
InMemoryCacheImpl(CacheDescriptor desc) |
Modifier and Type | Method and Description |
---|---|
Serializable |
get(String key)
Get method to retrieve value from cache Must not raise exception if the key is null, but return null
|
long |
getSize()
Returns this cache size (approximate number of entries), or
-1 if the number of entries is unknown or too
expensive to compute. |
boolean |
hasEntry(String key)
Check if a given key is present inside the cache.
|
void |
invalidate(String key)
Invalidate the given key
|
void |
invalidateAll()
Invalidate all key-value stored in the cache
|
void |
invalidateLocal(String key)
Invalidates the given key locally.
|
void |
invalidateLocalAll()
Invalidates all keys locally.
|
Set<String> |
keySet()
Returns the set of all keys stored in the cache.
|
void |
put(String key,
Serializable value)
Put method to store a
Serializable value |
void |
putLocal(String key,
Serializable value)
Stores a
Serializable value into the cache locally. |
getName, start, stop, toString
protected final com.google.common.cache.Cache<String,Serializable> cache
public InMemoryCacheImpl(CacheDescriptor desc)
public Serializable get(String key)
Cache
key
- the string keySerializable
value, return null if the key does not exist or if the key is nullpublic Set<String> keySet()
Cache
Set
of all keyspublic void invalidate(String key)
Cache
public void invalidateLocal(String key)
CacheManagement
key
- the key to remove from the cachepublic void invalidateAll()
Cache
public void invalidateLocalAll()
CacheManagement
public void put(String key, Serializable value)
Cache
Serializable
valuekey
- the string key, if null, the value will not be storedvalue
- the value to store, if null, the value will not be storedpublic void putLocal(String key, Serializable value)
CacheManagement
Serializable
value into the cache locally. Does not propagate invalidations.key
- the keyvalue
- the valuepublic boolean hasEntry(String key)
Cache
key
- the string keypublic long getSize()
CacheManagement
-1
if the number of entries is unknown or too
expensive to compute.-1
Copyright © 2019 Nuxeo. All rights reserved.