|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DataCache
Interface that must be implemented by any level 2 cache used by
OpenJPA. Most data caches will choose to implement the
Configurable
interface as well so that
they will be given the system configuration just after construction.
Implementations should take care not to return timed out data.
AbstractDataCache
,
DataCachePCData.isTimedOut()
Field Summary | |
---|---|
static java.lang.String |
NAME_DEFAULT
The name of the default data cache: default |
Method Summary | |
---|---|
void |
addExpirationListener(ExpirationListener listen)
Add a new expiration event listener to this cache. |
void |
clear()
Remove all data from this cache. |
void |
close()
Free the resources used by this cache. |
void |
commit(java.util.Collection additions,
java.util.Collection newUpdates,
java.util.Collection existingUpdates,
java.util.Collection deletes)
Perform a batch update of the cache. |
boolean |
contains(java.lang.Object oid)
Returns true if this cache contains data
corresponding to oid ; otherwise returns
false . |
java.util.BitSet |
containsAll(java.util.Collection oids)
Returns the indexes of the oids in this cache. |
DataCachePCData |
get(java.lang.Object oid)
Return the cached object for the given oid. |
java.lang.String |
getName()
Returns a string name that can be used by end-user-visible code to identify this cache. |
void |
initialize(DataCacheManager manager)
Initialize any resources associated with the given DataCacheManager . |
boolean |
pin(java.lang.Object oid)
Pin the value stored under oid into the cache. |
java.util.BitSet |
pinAll(java.util.Collection oids)
Pin all oids to the cache. |
DataCachePCData |
put(DataCachePCData value)
Set the cached value for the given instance. |
DataCachePCData |
remove(java.lang.Object oid)
Remove the value stored under the given oid. |
void |
removeAll(java.lang.Class cls,
boolean subclasses)
Evict all values of a specified type. |
java.util.BitSet |
removeAll(java.util.Collection oids)
Remove the values stored under the given oids. |
boolean |
removeExpirationListener(ExpirationListener listen)
Remove an expiration event listener from this cache. |
void |
setName(java.lang.String name)
Sets a string name to be used to identify this cache to end-user needs. |
boolean |
unpin(java.lang.Object oid)
Unpin the value stored under oid from the cache. |
java.util.BitSet |
unpinAll(java.util.Collection oids)
Unpin all oids from the cache. |
void |
update(DataCachePCData value)
Update the cached value for the given instance. |
void |
writeLock()
Obtain a write lock on the cache. |
void |
writeUnlock()
Release the write lock on the cache. |
Field Detail |
---|
static final java.lang.String NAME_DEFAULT
default
Method Detail |
---|
java.lang.String getName()
void setName(java.lang.String name)
void initialize(DataCacheManager manager)
DataCacheManager
.
void commit(java.util.Collection additions, java.util.Collection newUpdates, java.util.Collection existingUpdates, java.util.Collection deletes)
DataCachePCData
objects in additions
and in
newUpdates
, make the appropriate modifications to
all DataCachePCDatas in existingUpdates
, and delete all
OIDs in deletes
.
All changes made to cached data must be made via this
method. It is this method that is responsible for performing
any side-effects that should happen on meaningful cache changes.
Implementations should bear in mind that the
deletes
collection may contain oids that are also
in the additions
map. This is possible because it
is valid for a user to delete an object with a particular oid
and then add that object in the same batch.
additions
- A collection of DataCachePCData
objects.
These represent data that have been newly created,
and thus must be added to the cache.newUpdates
- A collection of DataCachePCData
objects.
These represent data that have been modified but
were not originally in the cache, and thus must be added to the cache.existingUpdates
- A collection of DataCachePCData
objects.
These represent data that have been modified and
were originally loaded from the cache. It is
up to the cache implementation to decide if
these values must be re-enlisted in the cache.
Some caches may return live data from get(java.lang.Object)
invocations, in which case these values need not be re-enlisted.deletes
- A collection of object IDs that have been deleted
and must therefore be dropped from the cache.boolean contains(java.lang.Object oid)
true
if this cache contains data
corresponding to oid
; otherwise returns
false
.
java.util.BitSet containsAll(java.util.Collection oids)
DataCachePCData get(java.lang.Object oid)
update(org.apache.openjpa.datacache.DataCachePCData)
method should be used to re-cache any changed objects.
DataCachePCData put(DataCachePCData value)
commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.
null
if
the value was not previously cached. See Map.put(K, V)
for more information.void update(DataCachePCData value)
commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.
A cache implementation may or may not return a live object
from get(java.lang.Object)
invocations. If an object retrieved from a
get(java.lang.Object)
operation needs to be updated, this method can be
invoked instead of invoking put(org.apache.openjpa.datacache.DataCachePCData)
. The DataCache implementation
can then make optimizations based on how its get(java.lang.Object)
method works.
DataCachePCData remove(java.lang.Object oid)
commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.
null
if
the oid was not previously cached. See Map.remove(java.lang.Object)
for more information.java.util.BitSet removeAll(java.util.Collection oids)
remove(java.lang.Object)
void removeAll(java.lang.Class cls, boolean subclasses)
void clear()
commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.
boolean pin(java.lang.Object oid)
oid
into the cache.
This method guarantees that oid
's value will not
be dropped by the caching algorithm. This method does not
affect the behavior of remove(java.lang.Object)
.
true
if oid
's value was
pinned into the cache; false
if the oid is not in the cache.java.util.BitSet pinAll(java.util.Collection oids)
pin(java.lang.Object)
boolean unpin(java.lang.Object oid)
oid
from the cache.
This method reverses a previous invocation of pin(java.lang.Object)
.
This method does not remove anything from the cache; it merely
makes oid
's value a candidate for flushing from the cache.
true
if oid
's value was
unpinned from the cache; false
if the
oid is not in the cache.java.util.BitSet unpinAll(java.util.Collection oids)
unpin(java.lang.Object)
void writeLock()
void writeUnlock()
void addExpirationListener(ExpirationListener listen)
boolean removeExpirationListener(ExpirationListener listen)
void close()
close
in interface org.apache.openjpa.lib.util.Closeable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |