|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface IDCache
Defines a reliable and efficient lookup of a persistent object instance
via its unique identifier. An IDCache works like a local hashtable of
global instance data.
It is recommended, but not required, that an IDCache implementation
provide a default no-args constructor. Other ctors may take additional
parameters to provide for size limits to be enforced during calls to
the putInstance method, or to automatically handle proactive
updates.
See
Persist.html
in the top level docs for overview information on caching.
| Method Summary | |
|---|---|
void |
cleanup()
Clean up any older items that have exceeded their time to live. |
void |
clear()
Remove all entries from this cache. |
SandCollectionMessage |
find(SandQueryMessage query)
Iterate through the cache finding all instances that match the given query and return the corresponding collection of all instances found. |
IDCacheCallback |
getCallback()
Returns the callback if one has been set. |
SandPersistMessage |
getInstance(long id)
Given a persistent ID, return the associated message instance. |
java.util.Map |
getMap()
Return the underlying map used by the cache. |
CacheStats |
getStats(int nold)
Return a CacheStats message showing the specified number of older items that will be replaced to free space. |
long |
getTimeToLiveMillis()
Return the millisecond time to live for this heap. |
boolean |
putInstance(SandPersistMessage msg)
Given a persistent messsage, store it in the cache. |
SandPersistMessage |
removeInstance(long id)
Given a persistent ID, remove it from the cache. |
void |
setCallback(IDCacheCallback callback)
Sets the callback for this cache. |
void |
setTimeToLiveMillis(long millis)
Set the millisecond time to live in the cache. |
| Method Detail |
|---|
boolean putInstance(SandPersistMessage msg)
An instance will always be replaced if its revision number is greater than that of the cached instance. If the revision number is the same, and the cache already contains an instance then the cache may choose to keep the instance it already has. This allows cache implementations to maintain their internal state without unnecessary updates.
SandPersistMessage getInstance(long id)
SandPersistMessage removeInstance(long id)
void clear()
java.util.Map getMap()
putInstance(org.sandev.basics.structs.SandPersistMessage) and removeInstance(long) methods should
be used for cache manipulation, and this method should only be
used for read-only access like iteration over the map's
contents. This method may throw a ConcurrentModificationException
and is not recommended for general use.
Returns null if the IDCache is not backed by a map.
SandCollectionMessage find(SandQueryMessage query)
CacheStats getStats(int nold)
IDCacheCallback getCallback()
void setCallback(IDCacheCallback callback)
long getTimeToLiveMillis()
void setTimeToLiveMillis(long millis)
void cleanup()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||