@ComponentProfile(since="3.8.0") public class ExpiringMapCache extends java.lang.Object implements Cache
net.jodah:expiringmap
hosted on
github.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
|
void |
close()
Closes the component.
|
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
|
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.
|
void |
put(java.lang.String key,
java.io.Serializable value)
Puts a serializable object into the cache.
|
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() |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
ExpiringMapCache |
withEventListener(ExpiringMapCacheListener p) |
ExpiringMapCache |
withExpiration(TimeInterval t) |
ExpiringMapCache |
withExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy p) |
ExpiringMapCache |
withMaxEntries(java.lang.Integer i) |
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface Cache
init
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface Cache
start
in interface ComponentLifecycle
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface Cache
stop
in interface ComponentLifecycle
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
close
in interface Cache
close
in interface ComponentLifecycle
public 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 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)