org.ozoneDB.core.storage
Class DelayCache
java.lang.Object
org.ozoneDB.core.storage.AbstractTrimmingCache
org.ozoneDB.core.storage.DelayCache
- All Implemented Interfaces:
- Cache, PropertyConfigurable, TrimmingCache
- Direct Known Subclasses:
- FixedSizeDelayCache, GcListeningDelayCache
- public class DelayCache
- extends AbstractTrimmingCache
- implements PropertyConfigurable
A cache with a fixed maximum number of objects in it. This cache grows
until it has reached its maximum, which can be set by maxCapacity. Once that
maximum has been reached, the least recently used object is thrown away when
a new object is put in the cache. This cache has, next to that maximum number
of elements, also a maximum time an element will remain in this cache. If
that time has expired the element will be removed from this cache also.
Reinserting an element (using the same key) causes the time for that element
to be reset.
Note: every instance creates its own thread for asynchronous removal of
items past their 'best before' time. The trimmed() method on the TrimHandler
is often but not always called asynchronously from that thread.
- Version:
- $Id: DelayCache.java,v 1.1.2.2 2004/04/10 10:06:51 per_nyfelt Exp $
- Author:
- Leo Mekenkamp (mind the anti sp@m)
Constructor Summary |
DelayCache(java.util.Properties properties,
java.lang.String prefix)
|
Method Summary |
java.util.Map |
copyToMap()
|
java.lang.Object |
get(java.lang.Object key)
Returns the object in this cache for the given key. |
int |
getDelay()
|
protected java.util.SortedSet |
getEntries()
|
protected java.util.Map |
getKeysToEntries()
|
int |
getMinSleepTime()
|
java.util.Collection |
getPropertyInfos()
Returns a Collection with all the properties this instance
supports. |
void |
put(java.lang.Object key,
java.lang.Object value)
Puts an object into the cache, along with its identifying key. |
java.lang.Object |
remove(java.lang.Object key)
Returns the object in this cache for the given key and removes it from
the cache. |
void |
setDelay(int delay)
|
void |
setMinSleepTime(int minSleepTime)
|
int |
size()
|
private void |
trim()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static final java.util.logging.Logger log
DELAY
public static final PropertyInfo DELAY
MINSLEEPTIME
public static final PropertyInfo MINSLEEPTIME
INITIALCAPACITY
public static final PropertyInfo INITIALCAPACITY
LOADFACTOR
public static final PropertyInfo LOADFACTOR
delay
private int delay
minSleepTime
private int minSleepTime
keysToEntries
private java.util.Map keysToEntries
entries
private java.util.SortedSet entries
trimThread
private DelayCache.TrimThread trimThread
sleepUntil
private volatile long sleepUntil
wakingUpAt
private volatile long wakingUpAt
DelayCache
public DelayCache(java.util.Properties properties,
java.lang.String prefix)
getKeysToEntries
protected final java.util.Map getKeysToEntries()
getEntries
protected final java.util.SortedSet getEntries()
getPropertyInfos
public java.util.Collection getPropertyInfos()
- Description copied from interface:
PropertyConfigurable
Returns a Collection
with all the properties this instance
supports.
- Specified by:
getPropertyInfos
in interface PropertyConfigurable
- Overrides:
getPropertyInfos
in class AbstractTrimmingCache
get
public java.lang.Object get(java.lang.Object key)
- Description copied from interface:
Cache
- Returns the object in this cache for the given key.
- Specified by:
get
in interface Cache
put
public void put(java.lang.Object key,
java.lang.Object value)
- Description copied from interface:
Cache
- Puts an object into the cache, along with its identifying key.
- Specified by:
put
in interface Cache
remove
public java.lang.Object remove(java.lang.Object key)
- Description copied from interface:
Cache
- Returns the object in this cache for the given key and removes it from
the cache.
- Specified by:
remove
in interface Cache
trim
private void trim()
size
public int size()
- Specified by:
size
in interface Cache
copyToMap
public java.util.Map copyToMap()
- Specified by:
copyToMap
in interface Cache
getDelay
public final int getDelay()
setDelay
public final void setDelay(int delay)
getMinSleepTime
public final int getMinSleepTime()
setMinSleepTime
public final void setMinSleepTime(int minSleepTime)
Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.