Rice Pastry API

rice.persistence
Class MemoryStorage

java.lang.Object
  |
  +--rice.persistence.MemoryStorage
All Implemented Interfaces:
Catalog, Storage

public class MemoryStorage
extends java.lang.Object
implements Storage

This class is an implementation of Storage which provides in-memory storage. This class is specifically *NOT* designed to provide persistent storage, and simply functions as an enhanced hash table.


Constructor Summary
MemoryStorage(rice.p2p.commonapi.IdFactory factory)
          Builds a MemoryStorage object.
 
Method Summary
 boolean exists(rice.p2p.commonapi.Id id)
          Returns whether or not the provided id exists
 void exists(rice.p2p.commonapi.Id id, rice.Continuation c)
          Returns whether or not the provided id exists, by returning a Boolean through receiveResult on c
 void getObject(rice.p2p.commonapi.Id id, rice.Continuation c)
          Returns the object identified by the given id, or null if there is no cooresponding object (through receiveResult on c).
 void getTotalSize(rice.Continuation c)
          Returns the total size of the stored data in bytes.The result is returned via the receiveResult method on the provided Continuation with an Integer representing the size.
 rice.p2p.commonapi.IdSet scan(rice.p2p.commonapi.IdRange range)
          Return the objects identified by the given range of ids.
 void scan(rice.p2p.commonapi.IdRange range, rice.Continuation c)
          Return the objects identified by the given range of ids.
 void store(rice.p2p.commonapi.Id id, java.io.Serializable obj, rice.Continuation c)
          Stores the object under the key id.
 void unstore(rice.p2p.commonapi.Id id, rice.Continuation c)
          Removes the object from the list of stored objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryStorage

public MemoryStorage(rice.p2p.commonapi.IdFactory factory)
Builds a MemoryStorage object.

Parameters:
factory - The factory to build protocol-specific Ids from.
Method Detail

store

public void store(rice.p2p.commonapi.Id id,
                  java.io.Serializable obj,
                  rice.Continuation c)
Stores the object under the key id. If there is already an object under id, that object is replaced. This method completes by calling recieveResult() of the provided continuation with the success or failure of the operation.

Specified by:
store in interface Storage
Parameters:
obj - The object to be made persistent.
id - The object's id.
c - The command to run once the operation is complete
Returns:
true if the action succeeds, else false.

unstore

public void unstore(rice.p2p.commonapi.Id id,
                    rice.Continuation c)
Removes the object from the list of stored objects. If the object was not in the cached list in the first place, nothing happens and false is returned. This method completes by calling recieveResult() of the provided continuation with the success or failure of the operation.

Specified by:
unstore in interface Storage
Parameters:
id - The object's persistence id
c - The command to run once the operation is complete
Returns:
true if the action succeeds, else false.

exists

public boolean exists(rice.p2p.commonapi.Id id)
Returns whether or not the provided id exists

Specified by:
exists in interface Catalog
Parameters:
id - The id to check
Returns:
Whether or not the given id is stored

exists

public void exists(rice.p2p.commonapi.Id id,
                   rice.Continuation c)
Returns whether or not the provided id exists, by returning a Boolean through receiveResult on c

Specified by:
exists in interface Catalog
Parameters:
id - The id to check
c - The command to run once the result is available

getObject

public void getObject(rice.p2p.commonapi.Id id,
                      rice.Continuation c)
Returns the object identified by the given id, or null if there is no cooresponding object (through receiveResult on c).

Specified by:
getObject in interface Catalog
Parameters:
id - The id of the object in question.
c - The command to run once the operation is complete

scan

public void scan(rice.p2p.commonapi.IdRange range,
                 rice.Continuation c)
Return the objects identified by the given range of ids. The IdSet returned contains the Ids of the stored objects. The range is partially inclusive, the lower range is inclusive, and the upper exclusive. When the operation is complete, the receiveResult() method is called on the provided continuation with a IdSet result containing the resulting IDs.

Specified by:
scan in interface Catalog
Parameters:
c - The command to run once the operation is complete

scan

public rice.p2p.commonapi.IdSet scan(rice.p2p.commonapi.IdRange range)
Return the objects identified by the given range of ids. The IdSet returned contains the Ids of the stored objects. The range is partially inclusive, the lower range is inclusive, and the upper exclusive. NOTE: This method blocks so if the behavior of this method changes and the guys don't fit in memory, this method may be deprecated.

Specified by:
scan in interface Catalog
Parameters:
range - The range to query
Returns:
The idset containg the keys

getTotalSize

public void getTotalSize(rice.Continuation c)
Returns the total size of the stored data in bytes.The result is returned via the receiveResult method on the provided Continuation with an Integer representing the size.

Specified by:
getTotalSize in interface Catalog
Parameters:
c - The command to run once the operation is complete

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection