org.archive.util
Interface ObjectIdentityCache<K,V>

Type Parameters:
V -
All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
CachedBdbMap, ObjectIdentityBdbCache, ObjectIdentityMemCache

public interface ObjectIdentityCache<K,V>
extends java.io.Closeable

An object cache for create-once-by-name-and-then-reuse objects. Objects are added, but never removed. Subsequent get()s using the same key will return the exact same object, UNLESS all such objects have been forgotten, in which case a new object MAY be returned. This allows implementors (such as ObjectIdentityBdbCache or CachedBdbMap) to page out (aka 'expunge') instances to persistent storage while they're not being used. However, as long as they are used (referenced), all requests for the same-named object will share a reference to the same object, and the object may be mutated in place without concern for explicitly persisting its state to disk.


Method Summary
 void close()
          close/release any associated resources
 V get(K key)
          get the object under the given key/name
 V getOrUse(K key, Supplier<V> supplierOrNull)
          get the object under the given key/name, using (and remembering) the object supplied by the supplier if no prior mapping exists
 java.util.Set<K> keySet()
          set of all keys
 int size()
          count of name-to-object contained
 void sync()
          force the persistent backend, if any, to be updated with all live object state
 

Method Detail

get

V get(K key)
get the object under the given key/name


getOrUse

V getOrUse(K key,
           Supplier<V> supplierOrNull)
get the object under the given key/name, using (and remembering) the object supplied by the supplier if no prior mapping exists


sync

void sync()
force the persistent backend, if any, to be updated with all live object state


close

void close()
close/release any associated resources

Specified by:
close in interface java.io.Closeable

size

int size()
count of name-to-object contained


keySet

java.util.Set<K> keySet()
set of all keys



Copyright © 2003-2011 Internet Archive. All Rights Reserved.