com.anthonyeden.lib.cache
Interface Cache

All Known Implementing Classes:
AbstractCache

public interface Cache

Base interface for Cache implementations.

Since:
1.1
Author:
Anthony Eden

Method Summary
 java.lang.Object get(java.lang.Object key)
          Get the value for the given key from the cache.
 int getTTL()
          Get the default time to live.
 void loadConfiguration(Configuration configuration)
          Load the Cache's configuration from the given Configuration object.
 void put(java.lang.Object key, java.lang.Object value)
          Insert a value into the cache.
 void put(java.lang.Object key, java.lang.Object value, int ttl)
          Insert a value into the cache with the specified time to live.
 void remove(java.lang.Object key)
          Remove a value from the cache.
 void setTTL(int ttl)
          Set the default time to live.
 

Method Detail

get

public java.lang.Object get(java.lang.Object key)
Get the value for the given key from the cache. This method may return null if there is no value or the value is expired.

Parameters:
key - The key
Returns:
The value or null

put

public void put(java.lang.Object key,
                java.lang.Object value)
Insert a value into the cache.

Parameters:
key - The key
value - The value

put

public void put(java.lang.Object key,
                java.lang.Object value,
                int ttl)
Insert a value into the cache with the specified time to live. The specified time to live overrides the default time to live. A value less than 0 is be considered as "infinate".

Parameters:
key - The key
value - The value
ttl - The time to live

remove

public void remove(java.lang.Object key)
Remove a value from the cache.

Parameters:
key - The key

getTTL

public int getTTL()
Get the default time to live.

Returns:
The default time to live

setTTL

public void setTTL(int ttl)
Set the default time to live.

Parameters:
ttl - The new default time to live

loadConfiguration

public void loadConfiguration(Configuration configuration)
                       throws ConfigurationException
Load the Cache's configuration from the given Configuration object.

Parameters:
configuration - The Configuration object
Throws:
ConfigurationException


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