ozone core API

org.ozoneDB.core.storage
Class FixedSizeDelayCache

java.lang.Object
  extended byorg.ozoneDB.core.storage.AbstractTrimmingCache
      extended byorg.ozoneDB.core.storage.DelayCache
          extended byorg.ozoneDB.core.storage.FixedSizeDelayCache
All Implemented Interfaces:
Cache, PropertyConfigurable, TrimmingCache

public class FixedSizeDelayCache
extends DelayCache

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: FixedSizeDelayCache.java,v 1.1.2.2 2004/04/10 10:06:51 per_nyfelt Exp $
Author:
Leo Mekenkamp (mind the anti sp@m)

Nested Class Summary
 
Nested classes inherited from class org.ozoneDB.core.storage.DelayCache
DelayCache.TimedEntry
 
Nested classes inherited from class org.ozoneDB.core.storage.TrimmingCache
TrimmingCache.TrimHandler
 
Field Summary
private static java.util.logging.Logger log
           
private  int maxCapacity
           
static PropertyInfo MAXCAPACITY
           
 
Fields inherited from class org.ozoneDB.core.storage.DelayCache
DELAY, INITIALCAPACITY, LOADFACTOR, MINSLEEPTIME
 
Fields inherited from class org.ozoneDB.core.storage.AbstractTrimmingCache
 
Constructor Summary
FixedSizeDelayCache(java.util.Properties properties, java.lang.String prefix)
           
 
Method Summary
 int getMaxCapacity()
           
 java.util.Collection getPropertyInfos()
          Returns a Collection with all the properties this instance supports.
private  void ourTrim()
           
 void put(java.lang.Object key, java.lang.Object value)
          Puts an object into the cache, along with its identifying key.
 void setMaxCapacity(int maxCapacity)
           
 
Methods inherited from class org.ozoneDB.core.storage.DelayCache
copyToMap, get, getDelay, getEntries, getKeysToEntries, getMinSleepTime, remove, setDelay, setMinSleepTime, size
 
Methods inherited from class org.ozoneDB.core.storage.AbstractTrimmingCache
getPrefix, getSynchronizer, getTrimHandler, setSynchronizer, setTrimHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ozoneDB.core.storage.PropertyConfigurable
getPrefix
 

Field Detail

log

private static final java.util.logging.Logger log

MAXCAPACITY

public static final PropertyInfo MAXCAPACITY

maxCapacity

private int maxCapacity
Constructor Detail

FixedSizeDelayCache

public FixedSizeDelayCache(java.util.Properties properties,
                           java.lang.String prefix)
Method Detail

setMaxCapacity

public final void setMaxCapacity(int maxCapacity)

getMaxCapacity

public final int getMaxCapacity()

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 DelayCache

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
Overrides:
put in class DelayCache

ourTrim

private void ourTrim()

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.