com.oroad.stxx.cache
Class SimpleCacheImpl

java.lang.Object
  extended bycom.oroad.stxx.cache.SimpleCacheImpl
All Implemented Interfaces:
Cache

public class SimpleCacheImpl
extends java.lang.Object
implements Cache

Basic implementation an LRU cache.

Author:
Don Brown

Constructor Summary
SimpleCacheImpl()
          Creates the cache
 
Method Summary
 void addCacheable(Cacheable cacheable)
          Adds an object to the cache
 void clear()
          Clears the cache of all cacheables
 void expire()
          Removes all the expired objects from the cache
 Cacheable getCacheable(java.lang.Object identifier)
          Gets a cached object
 java.lang.String getName()
          Gets the name of the cache
 int getSize()
          Gets the maximum number of objects it can cache
 void removeCacheable(java.lang.Object identifier)
          Removes a cached object
 void setName(java.lang.String name)
          Sets the name of the cache
 void setSize(int size)
          Sets the maximum number of objects it will cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCacheImpl

public SimpleCacheImpl()
Creates the cache

Method Detail

getName

public java.lang.String getName()
Gets the name of the cache

Specified by:
getName in interface Cache
Returns:
The name value

setName

public void setName(java.lang.String name)
Sets the name of the cache

Specified by:
setName in interface Cache
Parameters:
name - The name

getSize

public int getSize()
Gets the maximum number of objects it can cache

Specified by:
getSize in interface Cache
Returns:
The size value

setSize

public void setSize(int size)
Sets the maximum number of objects it will cache

Specified by:
setSize in interface Cache
Parameters:
size - The size of the cache

removeCacheable

public void removeCacheable(java.lang.Object identifier)
Removes a cached object

Specified by:
removeCacheable in interface Cache
Parameters:
identifier - The key of the object to remove

getCacheable

public Cacheable getCacheable(java.lang.Object identifier)
Gets a cached object

Specified by:
getCacheable in interface Cache
Parameters:
identifier - The key to find the object
Returns:
The cacheable value

expire

public void expire()
Removes all the expired objects from the cache

Specified by:
expire in interface Cache

addCacheable

public void addCacheable(Cacheable cacheable)
Adds an object to the cache

Specified by:
addCacheable in interface Cache
Parameters:
cacheable - The object to add

clear

public void clear()
Clears the cache of all cacheables

Specified by:
clear in interface Cache