Class Cache

  • All Implemented Interfaces:
    Map<Identifier,​CachedObject>

    public class Cache
    extends Object
    implements Map<Identifier,​CachedObject>
    This cache stores CachedObjects 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 interface Cacheable which 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.

    Use

    This contains CachedObjects but this does not mean you actually should ever make them. Since Cacheable objects are Identifiable, this means that simple invoking add(Cacheable) will create a cached object internally. Invoking get(java.lang.Object) will return a cached object whose value (via CachedObject.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 call Cleanup.

    Created by Jeff Gaynor
    on Nov 11, 2010 at 1:02:04 PM