public interface ICachePolicy<K,T>
Interface for cache policy.
The semantics of this interface are generally specified in terms of a hard reference cache backing a weak (or soft) reference cache. Examples of methods on the interface whose semantics are determined by the hard reference cache include:
iterator()
- visitation order and membership is determined by
the backing hard reference cache.entryIterator()
- visitation order and membership is determined
by the backing hard reference cache.size()
- membership is determined by the backing hard reference
cache.capacity()
- the capacity of the backing hard reference cache.#setListener()
- eviction notices are fired when entries are
evicted from the hard reference cache.size()
returns the
number of entries in the hard reference cache. Neither visitation of nor
counting of all weak cache entries in and of itself is not a foreseen use case
and those semantics not supported by this interface.
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Return the capacity of the hard reference cache.
|
void |
clear()
Clear all objects from the cache.
|
Iterator<ICacheEntry<K,T>> |
entryIterator()
Return an iterator that will visit the
ICacheEntry objects in the
cache. |
T |
get(K oid)
Return the indicated object from the cache or null if the object is not
in cache.
|
ICacheListener<K,T> |
getCacheListener()
Return the cache eviction listener.
|
Iterator<T> |
iterator()
Return an iterator that will visit the application objects in the cache.
|
void |
put(K oid,
T obj,
boolean dirty)
Insert or "touch" this object in the cache.
|
T |
remove(K oid)
Remove the indicated object from the cache.
|
void |
setListener(ICacheListener<K,T> listener)
Sets the cache eviction listener on the hard reference cache.
|
int |
size()
Return the #of entries in the hard reference cache.
|
void setListener(ICacheListener<K,T> listener)
listener
- The listener or null
to remove any listener.ICacheListener<K,T> getCacheListener()
void put(K oid, T obj, boolean dirty)
oid
- The object identifier.obj
- The object.dirty
- True iff the object is dirty.IllegalStateException
- If a different object is in the cache under the specified
object identifier.T get(K oid)
oid
- The object identifier.T remove(K oid)
oid
- The object identifier.null
if there was no object under that identifier.void clear()
Iterator<T> iterator()
Return an iterator that will visit the application objects in the cache. The visitation order is determined by the hard reference cache policy. If the cache policy is ordered, then the visitation order reflects that order.
entryIterator()
Iterator<ICacheEntry<K,T>> entryIterator()
Return an iterator that will visit the ICacheEntry
objects in the
cache. The visitation order is determined by the hard reference cache
policy. If the cache policy is ordered, then the visitation order
reflects that order.
Note: This method is used to force dirty objects in the cache to the persistence layer during a transaction commit since it visits entries and not referents, thereby providing access to the cache entry metadata.
ICacheEntry
objects. If this is a weak
reference cache, then the iterator visits the entries in the
delegate hard reference cache.ICacheEntry
,
iterator()
int size()
int capacity()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.