com.anthonyeden.lib.cache
Class AbstractCache

java.lang.Object
  extended bycom.anthonyeden.lib.cache.AbstractCache
All Implemented Interfaces:
Cache
Direct Known Subclasses:
InMemoryCache

public abstract class AbstractCache
extends java.lang.Object
implements Cache

Abstract implementation of the Cache interface. Cache implementations can use this class as a base class for their implementation.

Since:
1.1
Author:
Anthony Eden

Field Summary
static int DEFAULT_TTL
          The default TTL (-1 infinate).
protected  int ttl
          The default time to live.
 
Constructor Summary
AbstractCache()
           
 
Method Summary
 int getTTL()
          Get the default time to live for the cache.
protected  boolean isExpired(CacheEntry cacheEntry)
          Check to see if the given CacheEntry is expired.
 void loadConfiguration(Configuration configuration)
          Load the Cache's configuration from the given Configuration object.
 void setTTL(int ttl)
          Set the default time to live for the cache.
 void setTTL(java.lang.String ttl)
          Set the default time to live of the Cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.anthonyeden.lib.cache.Cache
get, put, put, remove
 

Field Detail

DEFAULT_TTL

public static final int DEFAULT_TTL
The default TTL (-1 infinate).

See Also:
Constant Field Values

ttl

protected int ttl
The default time to live.

Constructor Detail

AbstractCache

public AbstractCache()
Method Detail

getTTL

public int getTTL()
Get the default time to live for the cache. A value less than 0 is be considered as "infinate".

Specified by:
getTTL in interface Cache
Returns:
The default time to live

setTTL

public void setTTL(int ttl)
Set the default time to live for the cache. A value less than 0 is be considered as "infinate".

Specified by:
setTTL in interface Cache
Parameters:
ttl - The default time to live

setTTL

public void setTTL(java.lang.String ttl)
Set the default time to live of the Cache. This method is useful if the time to live is coming from a configuration String. If the String is null then the time to live is set to the value of AbstractCache.DEFAULT_TTL.

Parameters:
ttl - The default time to live as a String

isExpired

protected boolean isExpired(CacheEntry cacheEntry)
Check to see if the given CacheEntry is expired.

Parameters:
cacheEntry - The CacheEntry

loadConfiguration

public void loadConfiguration(Configuration configuration)
                       throws ConfigurationException
Load the Cache's configuration from the given Configuration object. This is a no-op implementation. Subclasses which require configuration can override it.

Specified by:
loadConfiguration in interface Cache
Parameters:
configuration - The Configuration object
Throws:
ConfigurationException


Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.