Class Cache
- java.lang.Object
- 
- edu.uiuc.ncsa.security.core.cache.Cache
 
- 
- All Implemented Interfaces:
- Map<Identifier,CachedObject>
 
 public class Cache extends Object implements Map<Identifier,CachedObject> This cache storesCachedObjects by a given key. The cached objects are always sorted by added date to the cache, which facilitates and optimizes aging retention policies. Each object to be cached should implement the interfaceCacheablewhich has a single method that gives back th associated key. This is used to retrieve objects from the cache (rather than cachedObjects which contain state about the entry and when it was made).Note that this is not tasked with saving cached objects or any other persistence activities. It is up to the application to set an manage its own policies. UseThis containsCachedObjects but this does not mean you actually should ever make them. SinceCacheableobjects areIdentifiable, this means that simple invokingadd(Cacheable)will create a cached object internally. Invokingget(java.lang.Object)will return a cached object whose value (viaCachedObject.getValue()is the original cacheable object. Generally in OA4MP all useful objects (transactions, clients and pretty much anything with an identifier associated with it) are cacheable. If you need to cache something, use this, set your policies for aging and periodically callCleanup.Created by Jeff Gaynor 
 on Nov 11, 2010 at 1:02:04 PM
- 
- 
Constructor SummaryConstructors Constructor Description Cache()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CachedObjectadd(Cacheable cacheable)Convenience method to add an object with its key to the cache.voidclear()booleancontainsKey(Object key)booleancontainsObject(Cacheable cacheable)Checks if the cacheable object is in this cache.booleancontainsValue(Object value)Set<Map.Entry<Identifier,CachedObject>>entrySet()CachedObjectget(Object key)PriorityQueue<CachedObject>getSortedList()Sorted list of cached items, ordered by timestamp.TreeMap<Identifier,CachedObject>getTheRealCache()booleanisEmpty()Set<Identifier>keySet()Collection<? extends Cacheable>objectValues()Get the objects that have been cached.voidput(CachedObject co)CachedObjectput(Identifier key, CachedObject value)Using this rather thanadd(edu.uiuc.ncsa.security.core.cache.Cacheable)will let you cache anything you please, even objects (like connections to servers) that are not inherentlyIdentifiable.voidputAll(Map<? extends Identifier,? extends CachedObject> m)CachedObjectremove(Object key)intsize()StringtoString()Collection<CachedObject>values()- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
 
- 
 
- 
- 
- 
Method Detail- 
addpublic CachedObject add(Cacheable cacheable) Convenience method to add an object with its key to the cache. This creates the CachedObject wrapper to manage its state. If the object already exists in the cache, it updates its value.- Parameters:
- cacheable-
- Returns:
 
 - 
getSortedListpublic PriorityQueue<CachedObject> getSortedList() Sorted list of cached items, ordered by timestamp.- Returns:
 
 - 
getTheRealCachepublic TreeMap<Identifier,CachedObject> getTheRealCache() 
 - 
clearpublic void clear() - Specified by:
- clearin interface- Map<Identifier,CachedObject>
 
 - 
sizepublic int size() - Specified by:
- sizein interface- Map<Identifier,CachedObject>
 
 - 
isEmptypublic boolean isEmpty() - Specified by:
- isEmptyin interface- Map<Identifier,CachedObject>
 
 - 
containsKeypublic boolean containsKey(Object key) - Specified by:
- containsKeyin interface- Map<Identifier,CachedObject>
 
 - 
containsObjectpublic boolean containsObject(Cacheable cacheable) Checks if the cacheable object is in this cache.- Parameters:
- cacheable-
- Returns:
 
 - 
objectValuespublic Collection<? extends Cacheable> objectValues() Get the objects that have been cached.- Returns:
 
 - 
containsValuepublic boolean containsValue(Object value) - Specified by:
- containsValuein interface- Map<Identifier,CachedObject>
 
 - 
getpublic CachedObject get(Object key) - Specified by:
- getin interface- Map<Identifier,CachedObject>
 
 - 
putpublic void put(CachedObject co) 
 - 
putpublic CachedObject put(Identifier key, CachedObject value) Using this rather thanadd(edu.uiuc.ncsa.security.core.cache.Cacheable)will let you cache anything you please, even objects (like connections to servers) that are not inherentlyIdentifiable.- Specified by:
- putin interface- Map<Identifier,CachedObject>
- Parameters:
- key-
- value-
- Returns:
 
 - 
removepublic CachedObject remove(Object key) - Specified by:
- removein interface- Map<Identifier,CachedObject>
 
 - 
putAllpublic void putAll(Map<? extends Identifier,? extends CachedObject> m) - Specified by:
- putAllin interface- Map<Identifier,CachedObject>
 
 - 
keySetpublic Set<Identifier> keySet() - Specified by:
- keySetin interface- Map<Identifier,CachedObject>
 
 - 
valuespublic Collection<CachedObject> values() - Specified by:
- valuesin interface- Map<Identifier,CachedObject>
 
 - 
entrySetpublic Set<Map.Entry<Identifier,CachedObject>> entrySet() - Specified by:
- entrySetin interface- Map<Identifier,CachedObject>
 
 
- 
 
-