Quadcap Embeddable Server

com.quadcap.util.collections.Cacheable Class Reference

Inheritance diagram for com.quadcap.util.collections.Cacheable:

Object List of all members.

Detailed Description

The construction of these objects needs to be managed by the cache object.

They are initialized using the anonymous 'store' object; it is the responsibility of the derived class to cast the anonymous store to the correct type.

Author:
Stan Bailes

Definition at line 53 of file Cacheable.java.

Public Member Functions

void init (Object store, Object key) throws IOException
 Initialization and (recycling).

boolean isDirty ()
 Read the dirty bit.

void setDirty (boolean d)
 Set the dirty bit.

int getRefCount ()
 Read the reference count.

synchronized void setRefCount (int x)
 Set the reference count.

synchronized void incrRefCount ()
 Increment the reference count.

synchronized void decrRefCount ()
 Decrement the reference count.

void setDListItem (DListItem d)
 Set the LRU back pointer.

DListItem getDListItem ()
 Get the LRU back pointer.

Object getKey ()
 Get the cache item's key.

void setKey (Object key)
 Set the cache item's key.

abstract Object getData ()
 Get the cache item's data.

abstract void setData (Object data)
 Set the cache item's data.

void flush () throws IOException
 Flush this item and clear the dirty bit.


Protected Attributes

Object key
 The key used to locate this item in the underlying store, as well as in the cache itself.

Object store

Package Attributes

boolean dirty = false
 has object been modified while in the cache?

int refCount = 0
 We reference-count the cache items to know when it's ok to flush older items to make room for new ones.

DListItem me
 Back pointer to my place in the LRU list.


Member Function Documentation

synchronized void com.quadcap.util.collections.Cacheable.decrRefCount  ) 
 

Decrement the reference count.

Definition at line 113 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.refCount.

Referenced by com.quadcap.util.collections.Cache.get(), and com.quadcap.util.collections.Cache.put().

void com.quadcap.util.collections.Cacheable.flush  )  throws IOException
 

Flush this item and clear the dirty bit.

Definition at line 148 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.dirty.

Referenced by com.quadcap.util.collections.Cache.flush(), and com.quadcap.util.collections.Cache.getCacheable().

abstract Object com.quadcap.util.collections.Cacheable.getData  )  [pure virtual]
 

Get the cache item's data.

Referenced by com.quadcap.util.collections.Cache.get().

DListItem com.quadcap.util.collections.Cacheable.getDListItem  ) 
 

Get the LRU back pointer.

Definition at line 123 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.me.

Referenced by com.quadcap.util.collections.Cache.getCacheable().

Object com.quadcap.util.collections.Cacheable.getKey  ) 
 

Get the cache item's key.

Definition at line 128 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.key.

Referenced by com.quadcap.util.collections.Cache.checkCache(), and com.quadcap.util.collections.Cache.getCacheable().

int com.quadcap.util.collections.Cacheable.getRefCount  ) 
 

Read the reference count.

Definition at line 98 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.refCount.

Referenced by com.quadcap.util.collections.Cache.getCacheable().

synchronized void com.quadcap.util.collections.Cacheable.incrRefCount  ) 
 

Increment the reference count.

Definition at line 108 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.refCount.

Referenced by com.quadcap.util.collections.Cache.getCacheable().

void com.quadcap.util.collections.Cacheable.init Object  store,
Object  key
throws IOException
 

Initialization and (recycling).

Definition at line 79 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.dirty, com.quadcap.util.collections.Cacheable.init(), com.quadcap.util.collections.Cacheable.key, and com.quadcap.util.collections.Cacheable.store.

Referenced by com.quadcap.util.collections.Cache.getCacheable(), and com.quadcap.util.collections.Cacheable.init().

boolean com.quadcap.util.collections.Cacheable.isDirty  ) 
 

Read the dirty bit.

Definition at line 88 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.dirty.

Referenced by com.quadcap.util.collections.Cache.getCacheable().

abstract void com.quadcap.util.collections.Cacheable.setData Object  data  )  [pure virtual]
 

Set the cache item's data.

Referenced by com.quadcap.util.collections.Cache.put().

void com.quadcap.util.collections.Cacheable.setDirty boolean  d  ) 
 

Set the dirty bit.

Definition at line 93 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.dirty, and com.quadcap.util.collections.Cacheable.setDirty().

Referenced by com.quadcap.util.collections.Cacheable.setDirty().

void com.quadcap.util.collections.Cacheable.setDListItem DListItem  d  ) 
 

Set the LRU back pointer.

Definition at line 118 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.me, and com.quadcap.util.collections.Cacheable.setDListItem().

Referenced by com.quadcap.util.collections.Cache.getCacheable(), and com.quadcap.util.collections.Cacheable.setDListItem().

void com.quadcap.util.collections.Cacheable.setKey Object  key  ) 
 

Set the cache item's key.

Definition at line 133 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.setKey().

Referenced by com.quadcap.util.collections.Cacheable.setKey().

synchronized void com.quadcap.util.collections.Cacheable.setRefCount int  x  ) 
 

Set the reference count.

Definition at line 103 of file Cacheable.java.

References com.quadcap.util.collections.Cacheable.refCount, and com.quadcap.util.collections.Cacheable.setRefCount().

Referenced by com.quadcap.util.collections.Cacheable.setRefCount().


Member Data Documentation

boolean com.quadcap.util.collections.Cacheable.dirty = false [package]
 

has object been modified while in the cache?

Definition at line 55 of file Cacheable.java.

Referenced by com.quadcap.util.collections.Cacheable.flush(), com.quadcap.util.collections.Cacheable.init(), com.quadcap.util.collections.Cacheable.isDirty(), and com.quadcap.util.collections.Cacheable.setDirty().

Object com.quadcap.util.collections.Cacheable.key [protected]
 

The key used to locate this item in the underlying store, as well as in the cache itself.

Definition at line 72 of file Cacheable.java.

Referenced by com.quadcap.util.collections.Cacheable.getKey(), and com.quadcap.util.collections.Cacheable.init().

DListItem com.quadcap.util.collections.Cacheable.me [package]
 

Back pointer to my place in the LRU list.

Definition at line 66 of file Cacheable.java.

Referenced by com.quadcap.util.collections.Cacheable.getDListItem(), and com.quadcap.util.collections.Cacheable.setDListItem().

int com.quadcap.util.collections.Cacheable.refCount = 0 [package]
 

We reference-count the cache items to know when it's ok to flush older items to make room for new ones.

We should probably keep some statistics which keep track of the percentage of cache items currently "in-use"; i.e., with refCount > 0

Definition at line 63 of file Cacheable.java.

Referenced by com.quadcap.util.collections.Cacheable.decrRefCount(), com.quadcap.util.collections.Cacheable.getRefCount(), com.quadcap.util.collections.Cacheable.incrRefCount(), and com.quadcap.util.collections.Cacheable.setRefCount().

Object com.quadcap.util.collections.Cacheable.store [protected]
 

Definition at line 74 of file Cacheable.java.

Referenced by com.quadcap.util.collections.Cacheable.init().