public interface Cache extends ComponentLifecycle
Modifier and Type | Method and Description |
---|---|
default void |
clear()
Clears all entries from the cache (optional operation).
|
java.lang.Object |
get(java.lang.String key)
Retrieves an object from the cache
|
default java.util.List<java.lang.String> |
getKeys()
Retrieves a List of all the keys in the cache (optional operation).
|
default void |
put(java.lang.String key,
java.lang.Object value)
Puts any object into the cache (optional operation).
|
default void |
put(java.lang.String key,
java.lang.Object value,
long ttl)
Puts an object into the cache, specifying a expiration (optional operation).
|
default void |
put(java.lang.String key,
java.lang.Object value,
TimeInterval expiry)
Puts an object into the cache, specifying a expiration (optional operation).
|
void |
put(java.lang.String key,
java.io.Serializable value)
Puts a serializable object into the cache.
|
default void |
put(java.lang.String key,
java.io.Serializable value,
long ttl)
Puts a serializable object into the cache, specifying a expiration (optional operation).
|
default void |
put(java.lang.String key,
java.io.Serializable value,
TimeInterval expiry)
Puts a serializable object into the cache, specifying a expiration (optional operation).
|
void |
remove(java.lang.String key)
Removes an object from the cache.
|
default int |
size() |
close, init, start, stop
void put(java.lang.String key, java.io.Serializable value) throws CoreException
key
- key to store the value againstvalue
- value to be storedCoreException
- if there was an exception accessing the cache.default void put(java.lang.String key, java.lang.Object value) throws CoreException
Not guaranteed to be supported by all cache implementations as some persistent caches require serialization.
key
- key to store the value againstvalue
- value to be storedjava.lang.UnsupportedOperationException
- if the operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.default void put(java.lang.String key, java.io.Serializable value, TimeInterval expiry) throws CoreException
Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.
key
- key to store the value againstvalue
- value to be storedexpiry
- the expiry expressed as a TimeInterval
CoreException
- if there was an exception accessing the cache.put(String, Serializable, long)
default void put(java.lang.String key, java.io.Serializable value, long ttl) throws CoreException
Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.
key
- key to store the value againstvalue
- value to be storedttl
- the TTL in milliseconds.java.lang.UnsupportedOperationException
- if the this operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.default void put(java.lang.String key, java.lang.Object value, TimeInterval expiry) throws CoreException
Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.
key
- key to store the value againstvalue
- value to be storedexpiry
- the expiry specified as a TimeIntervalCoreException
- if there was an exception accessing the cache.put(String, Object, long)
default void put(java.lang.String key, java.lang.Object value, long ttl) throws CoreException
Since JSR107 doesn't define per item cache expiry; this may not be supported by all cache implementations.
key
- key to store the value againstvalue
- value to be storedttl
- the TTL in milliseconds.java.lang.UnsupportedOperationException
- if the this operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.java.lang.Object get(java.lang.String key) throws CoreException
key
- the key to look up the objectCoreException
- if there was an exception accessing the cache.void remove(java.lang.String key) throws CoreException
key
- the key to locate the object in the cacheCoreException
- if there was an exception accessing the cache.default java.util.List<java.lang.String> getKeys() throws CoreException
java.lang.UnsupportedOperationException
- if the operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.default void clear() throws CoreException
java.lang.UnsupportedOperationException
- if the operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.default int size() throws CoreException
java.lang.UnsupportedOperationException
- if the operation is not supported by this cache instanceCoreException
- if there was an exception accessing the cache.UnsupportedOperationException
and performs no other action.