fabric.dissemination.pastry
Class Cache

java.lang.Object
  extended by fabric.dissemination.pastry.Cache

public class Cache
extends java.lang.Object

The cache object used by the disseminator to store globs. Essentially a hashtable specialized for globs; it also fetches globs directly from stores when needed.


Constructor Summary
Cache()
           
 
Method Summary
 Glob get(RemoteStore store, long onum)
          Retrieves a glob from the cache, without trying to fetch it from the store.
 Glob get(RemoteStore store, long onum, boolean fetch)
          Retrieves a glob from the cache, or fetches it from the store.
 void put(RemoteStore store, long onum, Glob g)
          Put given glob into the cache.
 java.util.List<Pair<Pair<Store,java.lang.Long>,java.lang.Long>> sortedTimestamps()
          Returns a snapshot set of the timestamp for each OID currently in the cache.
 java.util.Set<Pair<Pair<Store,java.lang.Long>,java.lang.Long>> timestamps()
          Returns a snapshot of the timestamp for each OID currently in the cache.
 boolean updateEntry(RemoteStore store, long onum, Glob g)
          Updates a cache entry with the given glob.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Method Detail

get

public Glob get(RemoteStore store,
                long onum)
Retrieves a glob from the cache, without trying to fetch it from the store.

Parameters:
store - the store of the object to retrieve.
onum - the onum of the object.
Returns:
the glob, if it is in the cache; null otherwise.

get

public Glob get(RemoteStore store,
                long onum,
                boolean fetch)
Retrieves a glob from the cache, or fetches it from the store.

Parameters:
store - the store of the object to retrieve.
onum - the onum of the object.
fetch - true if we should fetch from store.
Returns:
the glob, or null if fetch is false and glob does not exists in cache.

put

public void put(RemoteStore store,
                long onum,
                Glob g)
Put given glob into the cache.

Parameters:
store - the store of the object.
onum - the onum of the object.
g - the glob.

updateEntry

public boolean updateEntry(RemoteStore store,
                           long onum,
                           Glob g)
Updates a cache entry with the given glob. If the cache has no entry for the given oid, then nothing is changed.

Returns:
true iff there was a cache entry for the given oid.

timestamps

public java.util.Set<Pair<Pair<Store,java.lang.Long>,java.lang.Long>> timestamps()
Returns a snapshot of the timestamp for each OID currently in the cache. This set is NOT backed by the underlying map. If new keys are inserted or removed from the cache, they will not be reflected by the set returned. However, no synchronization is needed for working with the set.


sortedTimestamps

public java.util.List<Pair<Pair<Store,java.lang.Long>,java.lang.Long>> sortedTimestamps()
Returns a snapshot set of the timestamp for each OID currently in the cache. The set is sorted in descending order by the popularity of the corresponding objects. Like timestamps(), the returned set is not backed by the underlying table.