public interface CacheStorage
Modifier and Type | Interface and Description |
---|---|
static interface |
CacheStorage.EntryFilter |
static interface |
CacheStorage.EntryVisitor |
static interface |
CacheStorage.MultiThreadedContext |
static interface |
CacheStorage.VisitContext |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all entries from the cache and free resources.
|
void |
close()
Free all resources and stop operations immediately.
|
boolean |
contains(Object key)
Returns true if there is a mapping for the key.
|
StorageEntry |
get(Object key)
Retrieve the entry from the storage.
|
int |
getEntryCount() |
void |
put(StorageEntry e)
Stores the entry in the storage.
|
boolean |
remove(Object key) |
void |
visit(CacheStorage.VisitContext ctx,
CacheStorage.EntryFilter f,
CacheStorage.EntryVisitor v)
Iterate over all stored entries and call the entry visitor.
|
StorageEntry get(Object key) throws Exception
Depending on the cache configuration, an exception on get is not severe. The cache will try other sources or return null.
Exception
void put(StorageEntry e) throws Exception
If a put operation fails an implementation should try to remove an existing entry bound to the key and then throw the exception.
IOException
- may be thrown if hope is lostException
boolean contains(Object key) throws Exception
An exception on contains is not severe. The cache will try other sources or return null.
Exception
void clear() throws Exception
When a Cache.clear() is initiated there is no obligation to send a CacheStorage.clear() to the persisted storage. Alternatively, all objects can be removed via remove().
Exception
void close() throws Exception
Exception
void visit(CacheStorage.VisitContext ctx, CacheStorage.EntryFilter f, CacheStorage.EntryVisitor v) throws Exception
PurgeableStorage
is not
implemented, returning expired entries is a must, to support the generic purge
algorithm.
If the ExecutorService
is used, the method may return immediately without
the waiting for all threads to finish. This is done by the caller, when needed.
Exception
int getEntryCount()
cache2k API documentation. Copyright © 2000–2018 headissue GmbH, Munich.