Cache Class Reference

Collaboration diagram for Cache:

Collaboration graph
[legend]

List of all members.

Classes

class  DelayedMCElement

Public Types

enum  DeleteResponse { DELETED, NOT_FOUND }
enum  StoreResponse { STORED, NOT_STORED, EXISTS, NOT_FOUND }

Public Member Functions

StoreResponse add (MCElement e)
StoreResponse append (MCElement element)
 Cache (CacheStorage cacheStorage)
StoreResponse cas (Long cas_key, MCElement e)
DeleteResponse delete (String key, int time)
boolean flush_all (int expire)
boolean flush_all ()
MCElement get (String key)
Integer get_add (String key, int mod)
long getBytesRead ()
long getBytesWritten ()
long getCurrentBytes ()
long getCurrentItems ()
int getGetCmds ()
int getGetHits ()
int getGetMisses ()
long getLimitMaxBytes ()
int getSetCmds ()
int getTotalItems ()
Set< Stringkeys ()
StoreResponse prepend (MCElement element)
void processDeleteQueue ()
StoreResponse replace (MCElement e)
StoreResponse set (MCElement e)

Protected Member Functions

void initStats ()
boolean isBlocked (MCElement e)
boolean isExpired (MCElement e)
boolean isThere (String key)
final int Now ()

Protected Attributes

CacheStorage cacheStorage

Private Member Functions

void finishCacheRead ()
void finishCacheWrite ()
void startCacheRead ()
void startCacheWrite ()

Private Attributes

long bytesRead
long bytesWritten
final ReadWriteLock cacheReadWriteLock
long casCounter
int currentItems
DelayQueue< DelayedMCElementdeleteQueue
final ReadWriteLock deleteQueueReadWriteLock
int getCmds
int getHits
int getMisses
int setCmds
int totalItems


Member Enumeration Documentation

Enumerator:
DELETED 
NOT_FOUND 

Enumerator:
STORED 
NOT_STORED 
EXISTS 
NOT_FOUND 


Constructor & Destructor Documentation

Cache ( CacheStorage  cacheStorage  ) 

Construct the server session handler

Parameters:
cacheStorage the cache to use


Member Function Documentation

StoreResponse add ( MCElement  e  ) 

Add an element to the cache

Parameters:
e the element to add
Returns:
the store response code

StoreResponse append ( MCElement  element  ) 

Append bytes to the end of an element in the cache

Parameters:
element the element to append
Returns:
the store response code

StoreResponse cas ( Long  cas_key,
MCElement  e 
)

Set an element in the cache but only if the element has not been touched since the last 'gets'

Parameters:
cas_key the cas key returned by the last gets
e the element to set
Returns:
the store response code

DeleteResponse delete ( String  key,
int  time 
)

Handle the deletion of an item from the cache.

Parameters:
key the key for the item
time an amount of time to block this entry in the cache for further writes
Returns:
the message response

void finishCacheRead (  )  [private]

Blocks of code in which the contents of the cache are examined in any way must be surrounded by calls to startRead and finishRead. See documentation for ReadWriteLock.

void finishCacheWrite (  )  [private]

Blocks of code in which the contents of the cache are changed in any way must be surrounded by calls to startWrite and finishWrite. See documentation for ReadWriteLock.

boolean flush_all ( int  expire  ) 

Flush all cache entries with a timestamp after a given expiration time

Parameters:
expire the flush time in seconds
Returns:
command response

boolean flush_all (  ) 

Flush all cache entries

Returns:
command response

MCElement get ( String  key  ) 

Get an element from the cache

Parameters:
key the key for the element to lookup
Returns:
the element, or 'null' in case of cache miss.

Integer get_add ( String  key,
int  mod 
)

Increment an (integer) element inthe cache

Parameters:
key the key to increment
mod the amount to add to the value
Returns:
the message response

long getBytesRead (  ) 

long getBytesWritten (  ) 

long getCurrentBytes (  ) 

long getCurrentItems (  ) 

int getGetCmds (  ) 

int getGetHits (  ) 

int getGetMisses (  ) 

long getLimitMaxBytes (  ) 

int getSetCmds (  ) 

int getTotalItems (  ) 

void initStats (  )  [protected]

Initialize all statistic counters

boolean isBlocked ( MCElement  e  )  [protected]

boolean isExpired ( MCElement  e  )  [protected]

boolean isThere ( String  key  )  [protected]

Check whether an element is in the cache and non-expired and the slot is non-blocked

Parameters:
key the key for the element to lookup
Returns:
whether the element is in the cache and is live

Set<String> keys (  ) 

final int Now (  )  [protected]

Returns:
the current time in seconds (from epoch), used for expiries, etc.

StoreResponse prepend ( MCElement  element  ) 

Prepend bytes to the end of an element in the cache

Parameters:
element the element to append
Returns:
the store response code

void processDeleteQueue (  ) 

Executed periodically to clean from the cache those entries that are just blocking the insertion of new ones.

StoreResponse replace ( MCElement  e  ) 

Replace an element in the cache

Parameters:
e the element to replace
Returns:
the store response code

StoreResponse set ( MCElement  e  ) 

Set an element in the cache

Parameters:
e the element to set
Returns:
the store response code

void startCacheRead (  )  [private]

Blocks of code in which the contents of the cache are examined in any way must be surrounded by calls to startRead and finishRead. See documentation for ReadWriteLock.

void startCacheWrite (  )  [private]

Blocks of code in which the contents of the cache are changed in any way must be surrounded by calls to startWrite and finishWrite. See documentation for ReadWriteLock. protect the higher layers from implementation details.


Member Data Documentation

long bytesRead [private]

long bytesWritten [private]

final ReadWriteLock cacheReadWriteLock [private]

Read-write lock allows maximal concurrency, since readers can share access; only writers need sole access.

long casCounter [private]

int currentItems [private]

DelayQueue<DelayedMCElement> deleteQueue [private]

final ReadWriteLock deleteQueueReadWriteLock [private]

int getCmds [private]

int getHits [private]

int getMisses [private]

int setCmds [private]

int totalItems [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:31 2012 for Project Wonder by  doxygen 1.5.8