Class GeneralCache
- java.lang.Object
-
- org.apache.manifoldcf.core.cachemanager.GeneralCache
-
public class GeneralCache extends java.lang.ObjectGeneral cache class. This class will be statically instantiated. It contains all the structures needed to maintain a cache of objects, with both LRU flushing behavior, and timed expiration of objects. This cache is entirely local to a JVM and does NOT have any locking and synchronization semantics cross-JVM. That is handled at a higher level.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classGeneralCache.ExpirationTreeThis class represents a timed expiration tree.protected classGeneralCache.ExpirationTreeNodeThis class represents a node in the expiration tree.protected classGeneralCache.InvalidationTableThis class describes a table of invalidation keys, each of which points to a set of object records.protected classGeneralCache.ObjectClassRecordThis is a helper class for the ObjectClassTable.protected classGeneralCache.ObjectClassTableThis class describes a set of object classes, each with its own LRU behavior.protected classGeneralCache.ObjectRecordThis class represents a cached object.protected classGeneralCache.ObjectRecordTableThis class describes a table of object records, looked up by the unique object description.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String_rcsidGeneralCache.ExpirationTreeexpirationTreeprotected GeneralCache.ObjectRecordTablehashtableprotected GeneralCache.InvalidationTableinvalidationTableprotected GeneralCache.ObjectClassTableobjectClassTable
-
Constructor Summary
Constructors Constructor Description GeneralCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddeleteEntry(GeneralCache.ObjectRecord record)Delete a record from the cache.voiddeleteObject(java.lang.Object objectDescription)Delete a record from the cache.voidexpireRecords(long expireTime)Expire all records that have older expiration times than that passed in.longgetObjectCreationTime(java.lang.Object objectDescription)Get the creation time of an object in the cache.longgetObjectExpirationTime(java.lang.Object objectDescription)Get the expiration time for an object in the cache.StringSetgetObjectInvalidationKeys(java.lang.Object objectDescription)Get the invalidation keys for an object in the cache.voidinvalidateKeys(StringSet keys)Invalidate a set of keys.java.lang.Objectlookup(java.lang.Object objectDescription)Locate an object in the cache, and return it if found.voidsetObject(java.lang.Object objectDescription, java.lang.Object object, StringSet keys, long timestamp)Add a newly created object to the cache.voidsetObjectClass(java.lang.Object objectDescription, java.lang.String objectClass, int maxCount)Set an object's class and maximum count.voidsetObjectExpiration(java.lang.Object objectDescription, long expirationTime)Set an object's expiration time.
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
hashtable
protected GeneralCache.ObjectRecordTable hashtable
-
invalidationTable
protected GeneralCache.InvalidationTable invalidationTable
-
objectClassTable
protected GeneralCache.ObjectClassTable objectClassTable
-
expirationTree
public GeneralCache.ExpirationTree expirationTree
-
-
Method Detail
-
lookup
public java.lang.Object lookup(java.lang.Object objectDescription)
Locate an object in the cache, and return it if found.- Parameters:
objectDescription- is the object's unique identifier.- Returns:
- the object if found, or null if not present in the cache.
-
getObjectCreationTime
public long getObjectCreationTime(java.lang.Object objectDescription)
Get the creation time of an object in the cache.- Parameters:
objectDescription- is the object's unique identifier.- Returns:
- the creation time, or -1 if object not found.
-
getObjectInvalidationKeys
public StringSet getObjectInvalidationKeys(java.lang.Object objectDescription)
Get the invalidation keys for an object in the cache.- Parameters:
objectDescription- is the object's unique identifier.- Returns:
- the keys, or null if not found.
-
getObjectExpirationTime
public long getObjectExpirationTime(java.lang.Object objectDescription)
Get the expiration time for an object in the cache.- Parameters:
objectDescription- is the object's unique identifier.- Returns:
- the expiration time (-1L means none).
-
deleteObject
public void deleteObject(java.lang.Object objectDescription)
Delete a record from the cache.- Parameters:
objectDescription- is the unique description.
-
setObject
public void setObject(java.lang.Object objectDescription, java.lang.Object object, StringSet keys, long timestamp)Add a newly created object to the cache. Use ONLY for newly created objects!- Parameters:
objectDescription- is the newly created object's unique description.object- is the newly created object itself.keys- are the invalidation keys for the newly created object.timestamp- is the creation timestamp for this object (used for cross-JVM invalidation)
-
setObjectExpiration
public void setObjectExpiration(java.lang.Object objectDescription, long expirationTime)Set an object's expiration time.- Parameters:
objectDescription- is the object's unique description.expirationTime- is the object's new expiration time, in milliseconds since epoch.
-
setObjectClass
public void setObjectClass(java.lang.Object objectDescription, java.lang.String objectClass, int maxCount)Set an object's class and maximum count. This will clean up extra objects in a Least Recently Used fashion until the count is met.- Parameters:
objectDescription- is the object's unique description.objectClass- is the object's "class", or grouping for the purposes of LRU.maxCount- is the maximum number of objects of the class to permit to remain in the cache.
-
invalidateKeys
public void invalidateKeys(StringSet keys)
Invalidate a set of keys. This causes all objects that have any of the specified keys as invalidation keys to be removed from the cache.- Parameters:
keys- is the StringSet describing the keys to invalidate.
-
expireRecords
public void expireRecords(long expireTime)
Expire all records that have older expiration times than that passed in.- Parameters:
expireTime- is the time to compare against, in milliseconds since epoch.
-
deleteEntry
protected void deleteEntry(GeneralCache.ObjectRecord record)
Delete a record from the cache. NOTE WELL: This method cannot be used if the data associated with the record is currently being processed with an enumeration (for example), since it modifies the structures that the enumeration is based on!- Parameters:
record- is the object record.
-
-