|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrice.persistence.LRUCache
This class is an encapsulation of a least-recently-used (LRU) cache. It uses the provided storage service in order to store the cached data. If the Storage provides non-corruption services, these services will also be provided by this cache.
Constructor Summary | |
LRUCache(Storage storage,
int maximumSize)
Builds a LRU cache given a storage object to store the cached data in and a maximum cache size. |
Method Summary | |
void |
cache(Id id,
java.io.Serializable obj,
Continuation c)
Caches an object in this storage. |
boolean |
exists(Id id)
Returns whether or not an object is cached in the location id . |
void |
exists(Id id,
Continuation c)
Returns whether or not an object is cached in the location id . |
void |
getMaximumSize(Continuation c)
Returns the maximum size of the cache, in bytes. |
void |
getObject(Id id,
Continuation c)
Returns the object identified by the given id. |
void |
getTotalSize(Continuation c)
Returns the total size of the stored data in bytes. |
IdSet |
scan(IdRange range)
Return the objects identified by the given range of ids. |
void |
scan(IdRange range,
Continuation c)
Return the objects identified by the given range of ids. |
void |
setMaximumSize(int size,
Continuation c)
Sets the maximum size of the cache, in bytes. |
void |
uncache(Id id,
Continuation c)
Removes the object from the list of cached objects. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LRUCache(Storage storage, int maximumSize)
storage
- The storage service to use as a back-end storagemaximumSize
- The maximum size, in bytes, of storage to useMethod Detail |
public void cache(Id id, java.io.Serializable obj, Continuation c)
uncachr(id)
followed
by cache(id, obj)
. This method finishes by calling
receiveResult() on the provided continuation with whether or not
the object was cached. Note that the object may not actually be
cached due to the cache replacement policy.
Returns True
if the cache actaully stores the object, else
False
(through receiveResult on c).
cache
in interface Cache
id
- The object's id.obj
- The object to cache.c
- The command to run once the operation is completepublic void uncache(Id id, Continuation c)
False
is returned.
Returns True
if the action succeeds, else
False
(through receiveResult on c).
uncache
in interface Cache
c
- The command to run once the operation is completepublic boolean exists(Id id)
id
.
exists
in interface Catalog
id
- The id of the object in question.
public void exists(Id id, Continuation c)
id
.
The result is returned via the receiveResult method on the provided
Continuation with an Boolean represnting the result.
exists
in interface Catalog
c
- The command to run once the operation is completeid
- The id of the object in question.
public void getObject(Id id, Continuation c)
getObject
in interface Catalog
id
- The id of the object in question.c
- The command to run once the operation is complete
null
if there is no cooresponding
object (through receiveResult on c).public void scan(IdRange range, Continuation c)
scan
in interface Catalog
c
- The command to run once the operation is complete
public IdSet scan(IdRange range)
scan
in interface Catalog
range
- The range to query
public void getMaximumSize(Continuation c)
getMaximumSize
in interface Cache
c
- The command to run once the operation is completepublic void getTotalSize(Continuation c)
getTotalSize
in interface Catalog
c
- The command to run once the operation is complete
public void setMaximumSize(int size, Continuation c)
setMaximumSize
in interface Cache
size
- The new maximum size, in bytes, of the cache.c
- The command to run once the operation is complete
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |