@ComponentProfile(since="3.8.0") public class ExpiringMapCache extends java.lang.Object implements Cache
net.jodah:expiringmap
hosted on
github.
Note that this implementation supports all the operations defined in Cache
so you can use this if you need per-item
expiry and other features.
In the adapter configuration file this class is aliased as expiring-map-cache which is the preferred alternative to the fully qualified classname when building your configuration.
Constructor and Description |
---|
ExpiringMapCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all entries from the cache (optional operation).
|
long |
expiration() |
net.jodah.expiringmap.ExpirationPolicy |
expirationPolicy() |
java.lang.Object |
get(java.lang.String key)
Retrieves an object from the cache
|
ExpiringMapCacheListener |
getEventListener() |
TimeInterval |
getExpiration() |
net.jodah.expiringmap.ExpirationPolicy |
getExpirationPolicy() |
java.util.List<java.lang.String> |
getKeys()
Retrieves a List of all the keys in the cache (optional operation).
|
java.lang.Integer |
getMaxEntries() |
void |
init()
Initialises the component.
|
int |
maxEntries() |
void |
put(java.lang.String key,
java.lang.Object value)
Puts any object into the cache (optional operation).
|
void |
put(java.lang.String key,
java.lang.Object value,
long ttl)
Put an object into the cache with a specific expiration.
|
void |
put(java.lang.String key,
java.io.Serializable value)
Puts a serializable object into the cache.
|
void |
put(java.lang.String key,
java.io.Serializable value,
long ttl)
Put an object into the cache with a specific expiration.
|
void |
remove(java.lang.String key)
Removes an object from the cache.
|
void |
setEventListener(ExpiringMapCacheListener cacheListener) |
void |
setExpiration(TimeInterval expiration) |
void |
setExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy expirationPolicy) |
void |
setMaxEntries(java.lang.Integer maxEntries) |
int |
size() |
ExpiringMapCache |
withEventListener(ExpiringMapCacheListener p) |
ExpiringMapCache |
withExpiration(TimeInterval t) |
ExpiringMapCache |
withExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy p) |
ExpiringMapCache |
withMaxEntries(java.lang.Integer i) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, start, stop
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic void put(java.lang.String key, java.io.Serializable value) throws CoreException
Cache
put
in interface Cache
key
- key to store the value againstvalue
- value to be storedCoreException
- if there was an exception accessing the cache.public void put(java.lang.String key, java.lang.Object value) throws CoreException
Cache
Not guaranteed to be supported by all cache implementations as some persistent caches require serialization.
put
in interface Cache
key
- key to store the value againstvalue
- value to be storedCoreException
- if there was an exception accessing the cache.public void put(java.lang.String key, java.lang.Object value, long ttl) throws CoreException
Note that the underlying behaviour is to explicitly set the ExpirationPolicy
to be CREATED
for the object
overriding whatever has been configured as part of the cache itself.
put
in interface Cache
key
- key to store the value againstvalue
- value to be storedttl
- the TTL in milliseconds.CoreException
- if there was an exception accessing the cache.public void put(java.lang.String key, java.io.Serializable value, long ttl) throws CoreException
Note that the underlying behaviour is to explicitly set the ExpirationPolicy
to be CREATED
for the object
overriding whatever has been configured as part of the cache itself.
put
in interface Cache
key
- key to store the value againstvalue
- value to be storedttl
- the TTL in milliseconds.CoreException
- if there was an exception accessing the cache.public java.lang.Object get(java.lang.String key) throws CoreException
Cache
get
in interface Cache
key
- the key to look up the objectCoreException
- if there was an exception accessing the cache.public void remove(java.lang.String key) throws CoreException
Cache
remove
in interface Cache
key
- the key to locate the object in the cacheCoreException
- if there was an exception accessing the cache.public java.util.List<java.lang.String> getKeys() throws CoreException
Cache
getKeys
in interface Cache
CoreException
- if there was an exception accessing the cache.public void clear() throws CoreException
Cache
clear
in interface Cache
CoreException
- if there was an exception accessing the cache.public int size() throws CoreException
size
in interface Cache
CoreException
- if there was an exception accessing the cache.public java.lang.Integer getMaxEntries()
public void setMaxEntries(java.lang.Integer maxEntries)
public int maxEntries()
public TimeInterval getExpiration()
public void setExpiration(TimeInterval expiration)
public long expiration()
public ExpiringMapCacheListener getEventListener()
public void setEventListener(ExpiringMapCacheListener cacheListener)
public net.jodah.expiringmap.ExpirationPolicy getExpirationPolicy()
public void setExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy expirationPolicy)
public net.jodah.expiringmap.ExpirationPolicy expirationPolicy()
public ExpiringMapCache withMaxEntries(java.lang.Integer i)
public ExpiringMapCache withExpiration(TimeInterval t)
public ExpiringMapCache withExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy p)
public ExpiringMapCache withEventListener(ExpiringMapCacheListener p)