|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.util.TimedCache
The TimedCache
is an implementation of a cache that
is based around an expiration timer. The underlying data store
of the cache is a HashMap
, so objects are stored
and retrieved from the cache using a (preferably immutable) key.
Note that this implementation does not permit null keys. Any use
of a null key will result in a NullPointerException
being thrown.
When storing an object in the cache, an expiration delay should
be specified which indicates how long that object will be stored
in the cache, without being accessed, before it is removed from
the cache. The default expiration time, if none is specified,
is 10 minutes per object. As long as the object is accessed,
via the get()
method, the object will remain in
the cache. Expiration times can be specified on a per-object
basis. The value NEVER_EXPIRES, as the name implies, can also
be specified to prevent expiration of the object.
Field Summary | |
static int |
DEFAULT_EXPIRATION
The default expiration (in minutes) for an instance of a timer cache that was created without a specified expiration. |
static int |
MAXIMUM_EXPIRATION
The maximum expiration (in minutes) that can be set on any object or as the default. |
static int |
NEVER_EXPIRES
The constant to specify in place of an expiration time to indicate that the given object should never expire. |
Constructor Summary | |
TimedCache()
Constructs a new, empty TimedCache instance
with default expiration on objects added to the cache. |
|
TimedCache(int defaultExpiration)
Constructs a new, empty TimedCache instance
with the specified default expiration on objects added to the cache
without an expiration time. |
Method Summary | |
void |
clear()
Clears the contents of this cache. |
java.lang.Object |
get(java.lang.Object key)
Retrieves a previously cached object from the cache. |
void |
put(java.lang.Object key,
java.lang.Object value)
Stores an object into the cache. |
void |
put(java.lang.Object key,
java.lang.Object value,
int expiration)
Stores an object into the cache. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from the cache if present |
void |
setDefaultExpiration(int expiration)
Changes the default expiration used by the cache for objects stored in the cache without an explicit expiration. |
void |
setExpiration(java.lang.Object key,
int expiration)
Changes the expiration on a previously cached object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_EXPIRATION
public static final int MAXIMUM_EXPIRATION
public static final int NEVER_EXPIRES
TimedCache
instance.
Constructor Detail |
public TimedCache()
TimedCache
instance
with default expiration on objects added to the cache.
public TimedCache(int defaultExpiration)
TimedCache
instance
with the specified default expiration on objects added to the cache
without an expiration time.
defaultExpiration
- the expiration (in minutes) to set by
default, or DEFAULT_EXPIRATION for the default, or
NEVER_EXPIRESMethod Detail |
public java.lang.Object get(java.lang.Object key)
key
- the search key for locating the cached object
public void put(java.lang.Object key, java.lang.Object value)
key
- the search key for determing the storage locationvalue
- the object to storepublic void put(java.lang.Object key, java.lang.Object value, int expiration)
key
- the search key for determing the storage locationvalue
- the object to storeexpiration
- the new expiration time in minutes to set,
or DEFAULT_EXPIRATION for the default, or
NEVER_EXPIRESpublic java.lang.Object remove(java.lang.Object key)
key
- the key for looking up the cache object to remove
null
if no there was no mapping for the keypublic void setDefaultExpiration(int expiration)
public void setExpiration(java.lang.Object key, int expiration)
key
- the search key for locating the cached objectexpiration
- the new expiration time in minutes to set,
or DEFAULT_EXPIRATION for the default, or
NEVER_EXPIRESpublic void clear()
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.