com.foxsmart.ic.util
Class ExpirableCache

java.lang.Object
  extended by com.foxsmart.ic.util.ExpirableCache

public class ExpirableCache
extends java.lang.Object

This class provides a cache where each element can be expired after a period of time. It is up to the caller to provide a unique key that isn't used by anybody else in the application.


Method Summary
static void add(java.lang.String key, java.lang.Object cacheEntry, java.lang.Integer timeoutSecs)
          Adds an entry into the cache using a specified key.
static java.lang.Object get(java.lang.String key)
          Gets an item in the cache.
static boolean isCached(java.lang.String key)
          Returns whether an item with the specified key is currently in the cache.
static java.lang.Object remove(java.lang.String key)
          Removes an item from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static void add(java.lang.String key,
                       java.lang.Object cacheEntry,
                       java.lang.Integer timeoutSecs)
Adds an entry into the cache using a specified key.

Parameters:
key - The key into the cache
cacheEntry - The cached entry
timeoutSecs - An optional timeout value in seconds. If null, the item is not timed out.

isCached

public static boolean isCached(java.lang.String key)
Returns whether an item with the specified key is currently in the cache. Any expired items will not be in the cache.

Parameters:
key - The key into the cache
Returns:
True if the item is in the cache or false if not.

get

public static java.lang.Object get(java.lang.String key)
Gets an item in the cache.

Parameters:
key - The key into the cache
Returns:
The item in the cache or null if there is no item with the key in the cache

remove

public static java.lang.Object remove(java.lang.String key)
Removes an item from the cache.

Parameters:
key - The key of the item in the cache to remove.
Returns:
The item that is being removed from the cache.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.