public class ItemStateReferenceCache extends Object implements ItemStateCache
ItemStateReferenceCache internally consists of 2 components:
 ItemStateReferenceMap serving as the primary (or main)
 cache; it holds weak references to ItemState instances. This
 ItemStateCache implementation directly represents the
 contents of the primary cache, i.e. isCached(ItemId),
 retrieve(ItemId)}, isEmpty() etc. only refer to the contents
 of the primary cache.ItemStateCache implementing a custom eviction policy and
 serving as the secondary (or auxiliary) cache; entries that are automatically
 flushed from this secondary cache through its eviction policy (LRU, etc.)
 will be indirectly flushed from the primary (reference) cache by the garbage
 collector if they are thus rendered weakly reachable.
 This implementation of ItemStateCache is thread-safe.
| Constructor and Description | 
|---|
| ItemStateReferenceCache(ItemStateCache cache)Creates a new  ItemStateReferenceCachethat uses the
 specifiedItemStateCacheinstance as internal secondary
 cache. | 
| ItemStateReferenceCache(ItemStateCacheFactory cacheFactory)Creates a new  ItemStateReferenceCachethat uses aMLRUItemStateCacheinstance as internal cache. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | cache(ItemState state)Stores the specified  ItemStateobject in the map
 using itsItemIdas the key. | 
| void | dispose()Informs the cache that it is no longer in use. | 
| void | evict(ItemId id)Removes the  ItemStateobject with the specified id from
 this cache if it is present. | 
| void | evictAll()Clears all entries from this cache. | 
| boolean | isCached(ItemId id)Returns  trueif this cache contains anItemStateobject with the specifiedid. | 
| boolean | isEmpty()Returns  trueif this cache contains no entries. | 
| ItemState | retrieve(ItemId id)Returns the  ItemStateobject with the specifiedidif it is present ornullif no entry exists
 with thatid. | 
| ItemState[] | retrieveAll()Returns all the cached item states. | 
public ItemStateReferenceCache(ItemStateCacheFactory cacheFactory)
ItemStateReferenceCache that uses a
 MLRUItemStateCache instance as internal cache.public ItemStateReferenceCache(ItemStateCache cache)
ItemStateReferenceCache that uses the
 specified ItemStateCache instance as internal secondary
 cache.cache - secondary cache implementing a custom eviction policypublic boolean isCached(ItemId id)
true if this cache contains an ItemState
 object with the specified id.isCached in interface ItemStateCacheid - id of ItemState object whose presence should be
           tested.true if there's a corresponding cache entry,
         otherwise false.public ItemState retrieve(ItemId id)
ItemState object with the specified
 id if it is present or null if no entry exists
 with that id.retrieve in interface ItemStateCacheid - the id of the ItemState object to be returned.ItemState object with the specified
         id or or null if no entry exists
         with that idpublic ItemState[] retrieveAll()
retrieveAll in interface ItemStateCachepublic void cache(ItemState state)
ItemState object in the map
 using its ItemId as the key.cache in interface ItemStateCachestate - the ItemState object to cachepublic void evict(ItemId id)
ItemState object with the specified id from
 this cache if it is present.evict in interface ItemStateCacheid - the id of the ItemState object which should be
           removed from this cache.public void dispose()
dispose in interface ItemStateCachepublic void evictAll()
evictAll in interface ItemStateCachepublic boolean isEmpty()
true if this cache contains no entries.isEmpty in interface ItemStateCachetrue if this cache contains no entries.Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.