Rice Pastry API

rice.persistence
Interface Cache

All Superinterfaces:
Catalog
All Known Subinterfaces:
StorageManager
All Known Implementing Classes:
EmptyCache, LRUCache, StorageManagerImpl

public interface Cache
extends Catalog

This interface is the abstraction of something which provides a caching service. Implementations should take in parameters specific to the cache algorithm. Two implementations are provided, the LRUCache and GDSCache. This interface extends the Catalog interface, as the cache provides a Catalog service.

Version:
$Id: Cache.java 4654 2009-01-08 16:33:07Z jeffh $

Method Summary
 void cache(Id id, java.io.Serializable metadata, java.io.Serializable obj, Continuation c)
          Caches an object in this storage.
 long getMaximumSize()
          Returns the maximum size of the cache, in bytes.
 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 interface rice.persistence.Catalog
exists, flush, getMetadata, getObject, getSize, getTotalSize, rename, scan, scan, scanMetadata, scanMetadata, scanMetadataValuesHead, scanMetadataValuesNull, setMetadata
 

Method Detail

cache

void cache(Id id,
           java.io.Serializable metadata,
           java.io.Serializable obj,
           Continuation c)
Caches an object in this storage. This method is non-blocking. If the object has already been stored at the location id, this method has the effect of calling uncache(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).

Parameters:
id - The object's id.
metadata - The object's metdatadata
obj - The object to cache.
c - The command to run once the operation is complete

uncache

void uncache(Id id,
             Continuation c)
Removes the object from the list of cached objects. This method is non-blocking. If the object was not in the cached list in the first place, nothing happens and False is returned. Returns True if the action succeeds, else False (through receiveResult on c).

Parameters:
pid - The object's id
c - The command to run once the operation is complete

getMaximumSize

long getMaximumSize()
Returns the maximum size of the cache, in bytes. The result is returned via the receiveResult method on the provided Continuation with an Integer representing the size.

Parameters:
c - The command to run once the operation is complete

setMaximumSize

void setMaximumSize(int size,
                    Continuation c)
Sets the maximum size of the cache, in bytes. Setting this value to a smaller value than the current value may result in object being evicted from the cache. Returns the success or failure of the setSize operation (through receiveResult on c).

Parameters:
size - The new maximum size, in bytes, of the cache.
c - The command to run once the operation is complete

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection