Rice Pastry API

rice.persistence
Interface Cache

All Superinterfaces:
Catalog
All Known Implementing Classes:
LRUCache, StorageManager

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,v 1.5 2003/06/11 18:02:43 amislove Exp $

Method Summary
 void cache(rice.p2p.commonapi.Id id, java.io.Serializable obj, rice.Continuation c)
          Caches an object in this storage.
 void getMaximumSize(rice.Continuation c)
          Returns the maximum size of the cache, in bytes.
 void setMaximumSize(int size, rice.Continuation c)
          Sets the maximum size of the cache, in bytes.
 void uncache(rice.p2p.commonapi.Id id, rice.Continuation c)
          Removes the object from the list of cached objects.
 
Methods inherited from interface rice.persistence.Catalog
exists, exists, getObject, getTotalSize, scan, scan
 

Method Detail

cache

public void cache(rice.p2p.commonapi.Id id,
                  java.io.Serializable obj,
                  rice.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 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).

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

uncache

public void uncache(rice.p2p.commonapi.Id id,
                    rice.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:
c - The command to run once the operation is complete

getMaximumSize

public void getMaximumSize(rice.Continuation c)
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

public void setMaximumSize(int size,
                           rice.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 - Rice Pastry.


Imprint-Dataprotection