com.sibvisions.util
Class ObjectCache

java.lang.Object
  extended by com.sibvisions.util.ObjectCache

public final class ObjectCache
extends java.lang.Object

The ObjectCache is a utility class to cache/store objects for a period of time. The cache handles the object expiration and the access to the cached objects. The cache stores an object with a unique access key. With this access key it's possible to access the object from the store.


Field Summary
static int TIMEOUT_INFINITE
          The constant that represents an infinite timeout.
 
Method Summary
static java.lang.Object createKey()
          Creates a random acces key.
static java.lang.Object get(java.lang.Object pKey)
          Gets an object from the cache.
static java.lang.Object put(IValidatable pObject)
          Puts a validatable object to the cache.
static java.lang.Object put(java.lang.Object pKey, IValidatable pObject)
          Puts a validatable object to the cache, with a specific key.
static java.lang.Object put(java.lang.Object pObject, long pTimeout)
          Puts an object to the cache, with a timeout for expiration.
static java.lang.Object put(java.lang.Object pKey, java.lang.Object pObject, long pTimeout)
          Puts an object to the cache, with a specific key and timeout for expiration.
static java.lang.Object remove(java.lang.Object pKey)
          Removes an object from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMEOUT_INFINITE

public static final int TIMEOUT_INFINITE
The constant that represents an infinite timeout.

See Also:
Constant Field Values
Method Detail

createKey

public static java.lang.Object createKey()
Creates a random acces key.

Returns:
the access key

put

public static java.lang.Object put(java.lang.Object pObject,
                                   long pTimeout)
Puts an object to the cache, with a timeout for expiration.

Parameters:
pObject - the cachable object
pTimeout - the timeout (in millis) for the object. After this time, the object will be removed from the cache
Returns:
the access key for the object

put

public static java.lang.Object put(IValidatable pObject)
Puts a validatable object to the cache.

Parameters:
pObject - the cachable object
Returns:
the access key for the object

put

public static java.lang.Object put(java.lang.Object pKey,
                                   java.lang.Object pObject,
                                   long pTimeout)
Puts an object to the cache, with a specific key and timeout for expiration.

Parameters:
pKey - the key for accessing the object
pObject - the cachable object
pTimeout - the timeout (in millis) for the object. After this time, the object will be removed from the cache
Returns:
the previous cached object or null if there was no previous object or the object is expired

put

public static java.lang.Object put(java.lang.Object pKey,
                                   IValidatable pObject)
Puts a validatable object to the cache, with a specific key.

Parameters:
pKey - the key for accessing the object
pObject - the cachable object
Returns:
the previous cached object or null if there was no previous object or the object is expired

get

public static java.lang.Object get(java.lang.Object pKey)
Gets an object from the cache.

Parameters:
pKey - the access key of the object
Returns:
the object or null if the object was expired or the key was not found

remove

public static java.lang.Object remove(java.lang.Object pKey)
Removes an object from the cache.

Parameters:
pKey - the access key of the object
Returns:
the removed object or null if the object was expired or the key was not found


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.