ConcurrentCache
public interface CacheManager
Modifier and Type | Method | Description |
---|---|---|
void |
ageOut() |
Age as many objects as possible out of the cache.
|
void |
clean(Matchable partialKey) |
Clean all objects that match the partialKey (or exact key).
|
void |
cleanAll() |
Place all objects in their clean state by calling their clean method
if they are dirty.
|
Cacheable |
create(java.lang.Object key,
java.lang.Object createParameter) |
Create an object in the cache.
|
void |
deregisterMBean() |
Deregister the MBean that monitors this cache.
|
boolean |
discard(Matchable partialKey) |
Discard all objects that match the partialKey (or exact key).
|
Cacheable |
find(java.lang.Object key) |
Find an object in the cache.
|
Cacheable |
findCached(java.lang.Object key) |
Find an object in the cache.
|
void |
registerMBean(java.lang.String dbName) |
Register an MBean that allows user to monitor this cache instance.
|
void |
release(Cacheable entry) |
Release a
Cacheable object previously found with
find() or findCached() , or created with
create() , and which is still kept by the caller. |
void |
remove(Cacheable entry) |
Delete and remove an object from the cache.
|
void |
shutdown() |
Shutdown the cache.
|
void |
useDaemonService(DaemonService daemon) |
This cache can use this DaemonService if it needs some work to be done
in the background.
|
java.util.Collection |
values() |
Return a Collection of the Cacheables currently in the
cache.
|
Cacheable find(java.lang.Object key) throws StandardException
Find an object in the cache that matches the key provided using the equals() method, i.e. the return Cacheable will have getIdentifier.equals(key) true. If the object does not exist in the cache it will be added by one of:
Page p = (Page) pageCache.find(pageKey); // do stuff with p // release p pageCache.release(p); p = null;
StandardException
- Standard Derby error policy.Cacheable.setIdentity(java.lang.Object)
Cacheable findCached(java.lang.Object key) throws StandardException
Find an object in the cache that matches the key provided using the equals()
method, i.e. the return Cacheable will have getIdentifier.equals(key) true.
If a matching object does not exist in the cache, null is returned.
The returned object is kept, i.e. its identity will not change, until the release()
method is called. The release() method must be called after the caller is finished
with the object and throw away the reference to it, e.g.
Page p = (Page) pageCache.findCached(pageKey); if (p != null) { // do stuff with p // release p pageCache.release(p); p = null; }
StandardException
- Standard Derby error policy.Cacheable create(java.lang.Object key, java.lang.Object createParameter) throws StandardException
Page p = (Page) pageCache.create(pageKey, createType); // do stuff with p // release p pageCache.release(p); p = null;
StandardException
- Standard Derby error policy.Cacheable.createIdentity(java.lang.Object, java.lang.Object)
void release(Cacheable entry)
Cacheable
object previously found with
find()
or findCached()
, or created with
create()
, and which is still kept by the caller.
After this call the caller must throw away the reference to item.entry
- the cached object to releasevoid remove(Cacheable entry) throws StandardException
find()
or
findCached()
, or created with create()
, and
it must still be kept by the caller.
The item will be placed into the NoIdentity
state through clean(true) (if required) and clearIdentity(). The removal of the
object will be delayed until it is not kept by anyone. Objects that are in the
to be removed state can still be found through find() and findCached()
until their keep count drops to zero. This call waits until the object
has been removed.
entry
- the object to remove from the cacheStandardException
- Standard Derby error policy.void cleanAll() throws StandardException
StandardException
- Standard Derby error policy.Cacheable.clean(boolean)
,
Cacheable.isDirty()
void clean(Matchable partialKey) throws StandardException
In order to clean more than one object the Cacheable equals method must be able to handle a partial key, e.g. a page has PageKey but a clean may pass a ContainerKey which will discard all pages in that container.
StandardException
- Standard Derby error policy.void ageOut()
void shutdown() throws StandardException
find()
,
findCached()
or create()
call,
and then cleanAll() and ageOut() are called. The cache remains
in existence until the last kept object has been unkept.StandardException
- Standard Derby error policy.void useDaemonService(DaemonService daemon)
boolean discard(Matchable partialKey)
If partialKey is null, it matches all objects. This is a way to discard all objects from the cache in case of emergency shutdown.
In order to discard more than one object the Cacheable equals method must be able to handle a partial key, e.g. a page has PageKey but a discard may pass a ContainerKey which will discard all pages in that container.
java.util.Collection values()
This method should only be used for diagnostic purposes.
void registerMBean(java.lang.String dbName) throws StandardException
Register an MBean that allows user to monitor this cache instance. This is a no-op if the platform does not support Java Management Extensions (JMX).
The MBean will be automatically deregistered when shutdown()
is called, or it can be manually deregistered by calling
deregisterMBean()
.
dbName
- the unique name of the database to which the cache belongsStandardException
- if an error occurs when registering the MBeanvoid deregisterMBean()
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.