public class ObjectIdentityBdbManualCache<V extends IdentityCacheable> extends Object implements ObjectIdentityCache<V>, Closeable, Serializable, com.google.common.collect.MapEvictionListener<String,V>
Modifier and Type | Field and Description |
---|---|
protected AtomicLong |
count |
protected com.sleepycat.je.Database |
db
The BDB JE database used for this instance.
|
protected ConcurrentMap<String,V> |
dirtyItems |
protected com.sleepycat.collections.StoredSortedMap<String,V> |
diskMap
The Collection view of the BDB JE database used for this instance.
|
protected ConcurrentMap<String,V> |
memMap
in-memory map of new/recent/still-referenced-elsewhere instances
|
Constructor and Description |
---|
ObjectIdentityBdbManualCache()
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
|
void |
onEviction(String key,
V val) |
protected com.sleepycat.je.Database |
openDatabase(com.sleepycat.je.Environment environment,
String dbName) |
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 ConcurrentMap<String,V extends IdentityCacheable> memMap
protected transient com.sleepycat.collections.StoredSortedMap<String,V extends IdentityCacheable> diskMap
protected transient ConcurrentMap<String,V extends IdentityCacheable> dirtyItems
protected AtomicLong count
public ObjectIdentityBdbManualCache()
#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>
public void onEviction(String key, V val)
onEviction
in interface com.google.common.collect.MapEvictionListener<String,V extends IdentityCacheable>
Copyright © 2003-2014 Internet Archive. All Rights Reserved.