public class ObjectIdentityBdbCache<V extends IdentityCacheable> extends Object implements ObjectIdentityCache<V>, Closeable, Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
ObjectIdentityBdbCache.LowMemoryCanary |
Modifier and Type | Field and Description |
---|---|
protected SoftReference<ObjectIdentityBdbCache.LowMemoryCanary> |
canary |
protected AtomicLong |
count |
protected com.sleepycat.je.Database |
db
The BDB JE database used for this instance.
|
protected com.sleepycat.collections.StoredSortedMap<String,V> |
diskMap
The Collection view of the BDB JE database used for this instance.
|
protected ConcurrentHashMap<String,org.archive.util.ObjectIdentityBdbCache.SoftEntry<V>> |
memMap
in-memory map of new/recent/still-referenced-elsewhere instances
|
protected static Field |
referentField
Reference to the Reference#referent Field.
|
protected ReferenceQueue<V> |
refQueue |
Constructor and Description |
---|
ObjectIdentityBdbCache()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
close/release any associated resources
|
protected String |
composeCacheSummary() |
protected com.sleepycat.collections.StoredSortedMap<String,V> |
createDiskMap(com.sleepycat.je.Database database,
com.sleepycat.bind.serial.StoredClassCatalog classCatalog,
Class valueClass) |
void |
dirtyKey(String key)
force the persistent backend, if any, to eventually be updated with
live object state for the given key
|
protected void |
finalize() |
V |
get(String key)
get the object under the given key/name -- but should not mutate
object state
|
protected String |
getDatabaseName() |
V |
getOrUse(String 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
-- but should not mutate object state
|
void |
initialize(com.sleepycat.je.Environment env,
String dbName,
Class valueClass,
com.sleepycat.bind.serial.StoredClassCatalog classCatalog)
Call this method when you have an instance when you used the
default constructor or when you have a deserialized instance that you
want to reconnect with an extant bdbje environment.
|
Set<String> |
keySet()
set of all keys
|
protected com.sleepycat.je.Database |
openDatabase(com.sleepycat.je.Environment environment,
String dbName) |
protected void |
pageOutStaleEntries()
An incremental, poll-based expunger.
|
int |
size()
count of name-to-object contained
|
void |
sync()
Sync all in-memory map entries to backing disk store.
|
protected transient com.sleepycat.je.Database db
protected transient ConcurrentHashMap<String,org.archive.util.ObjectIdentityBdbCache.SoftEntry<V extends IdentityCacheable>> memMap
protected transient ReferenceQueue<V extends IdentityCacheable> refQueue
protected transient com.sleepycat.collections.StoredSortedMap<String,V extends IdentityCacheable> diskMap
protected AtomicLong count
protected static Field referentField
protected transient SoftReference<ObjectIdentityBdbCache.LowMemoryCanary> canary
public ObjectIdentityBdbCache()
#initialize(Environment, Class, Class, StoredClassCatalog)
to finish construction. Construction is two-stepped to support
reconnecting a deserialized CachedBdbMap with its backing bdbje
database.dbName
- Name of the backing db this instance should use.public void initialize(com.sleepycat.je.Environment env, String dbName, Class valueClass, com.sleepycat.bind.serial.StoredClassCatalog classCatalog) throws com.sleepycat.je.DatabaseException
#CachedBdbMap(File, String, Class, Class)
constructor.env
- keyClass
- valueClass
- classCatalog
- com.sleepycat.je.DatabaseException
protected com.sleepycat.collections.StoredSortedMap<String,V> createDiskMap(com.sleepycat.je.Database database, com.sleepycat.bind.serial.StoredClassCatalog classCatalog, Class valueClass)
protected com.sleepycat.je.Database openDatabase(com.sleepycat.je.Environment environment, String dbName) throws com.sleepycat.je.DatabaseException
com.sleepycat.je.DatabaseException
public void close()
ObjectIdentityCache
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ObjectIdentityCache<V extends IdentityCacheable>
protected void finalize() throws Throwable
public V get(String key)
ObjectIdentityCache
get
in interface ObjectIdentityCache<V extends IdentityCacheable>
public V getOrUse(String key, Supplier<V> supplierOrNull)
ObjectIdentityCache
getOrUse
in interface ObjectIdentityCache<V extends IdentityCacheable>
public Set<String> keySet()
ObjectIdentityCache
keySet
in interface ObjectIdentityCache<V extends IdentityCacheable>
protected String composeCacheSummary()
public int size()
ObjectIdentityCache
size
in interface ObjectIdentityCache<V extends IdentityCacheable>
protected String getDatabaseName()
public void sync()
sync
in interface ObjectIdentityCache<V extends IdentityCacheable>
public void dirtyKey(String key)
ObjectIdentityCache
dirtyKey
in interface ObjectIdentityCache<V extends IdentityCacheable>
protected void pageOutStaleEntries()
Copyright © 2003-2014 Internet Archive. All Rights Reserved.