com.knowgate.cache
Class ExpireableCache

java.lang.Object
  extended by java.lang.Thread
      extended by com.knowgate.cache.ExpireableCache
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
AttributedExpireableCache

public class ExpireableCache
extends java.lang.Thread

This class represents a cache that automatically expires objects when a certain fillness factor is reached.


Nested Class Summary
protected  class ExpireableCache.MyHeap
          Implement a simple heap that just returns the smallest long variable/Object key pair.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.util.Hashtable cache
           
protected  int capacity
           
protected  float expire_factor
           
protected  int hits
           
protected  long max_keep_alive
           
protected  int misses
           
protected  boolean shutdown
           
protected  ExpireableCache.MyHeap timestamps
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ExpireableCache(int capacity)
           
ExpireableCache(int capacity, float expire_factor, long max_keep_alive)
           
 
Method Summary
protected  void expireOver()
           
 java.lang.Object get(java.lang.Object key)
           
 int getCapacity()
           
 int getHits()
           
 int getMisses()
           
 int getUsage()
           
 void hit()
           
 void miss()
           
 void put(java.lang.Object key, java.lang.Object value)
           
 void remove(java.lang.Object key)
           
 void run()
           
 void setCapacity(int size)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cache

protected java.util.Hashtable cache

timestamps

protected ExpireableCache.MyHeap timestamps

capacity

protected int capacity

expire_factor

protected float expire_factor

hits

protected int hits

misses

protected int misses

shutdown

protected boolean shutdown

max_keep_alive

protected long max_keep_alive
Constructor Detail

ExpireableCache

public ExpireableCache(int capacity,
                       float expire_factor,
                       long max_keep_alive)

ExpireableCache

public ExpireableCache(int capacity)
Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object value)

get

public java.lang.Object get(java.lang.Object key)

remove

public void remove(java.lang.Object key)

expireOver

protected void expireOver()

setCapacity

public void setCapacity(int size)

getCapacity

public int getCapacity()

getUsage

public int getUsage()

getHits

public int getHits()

getMisses

public int getMisses()

hit

public void hit()

miss

public void miss()

shutdown

public void shutdown()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread