|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mapdb.EngineWrapper
org.mapdb.Caches.WeakSoftRef
public static class Caches.WeakSoftRef
Instance cache which uses SoftReference or WeakReference
Items can be removed from cache by Garbage Collector if
| Nested Class Summary | |
|---|---|
protected static interface |
Caches.WeakSoftRef.CacheItem
|
protected static class |
Caches.WeakSoftRef.CacheSoftItem<A>
|
protected static class |
Caches.WeakSoftRef.CacheWeakItem<A>
|
| Nested classes/interfaces inherited from class org.mapdb.EngineWrapper |
|---|
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper |
| Field Summary | |
|---|---|
protected LongConcurrentHashMap<Caches.WeakSoftRef.CacheItem> |
items
|
protected ReentrantLock[] |
locks
|
protected ReferenceQueue<Object> |
queue
|
protected Thread |
queueThread
|
protected boolean |
useWeakRef
|
| Fields inherited from class org.mapdb.EngineWrapper |
|---|
CLOSED |
| Fields inherited from interface org.mapdb.Engine |
|---|
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID |
| Constructor Summary | |
|---|---|
Caches.WeakSoftRef(Engine engine,
boolean useWeakRef,
boolean disableLocks)
|
|
| Method Summary | ||
|---|---|---|
void |
clearCache()
clears any underlying cache |
|
void |
close()
Close store/cache. |
|
|
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner. |
|
|
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache Recid must be a number returned by 'put' method. |
|
|
get(long recid,
Serializer<A> serializer)
Get existing record. |
|
|
put(A value,
Serializer<A> serializer)
Insert new record. |
|
void |
rollback()
Undoes all changes made in the current transaction. |
|
protected void |
runRefQueue()
Collects items from GC and removes them from cache |
|
|
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value. |
|
| Methods inherited from class org.mapdb.EngineWrapper |
|---|
canRollback, canSnapshot, checkClosed, closeListenerRegister, closeListenerUnregister, commit, compact, getSerializerPojo, getWrappedEngine, isClosed, isReadOnly, preallocate, preallocate, snapshot |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.mapdb.Engine |
|---|
canRollback, canSnapshot, closeListenerRegister, closeListenerUnregister, commit, compact, getSerializerPojo, isClosed, isReadOnly, preallocate, preallocate, snapshot |
| Field Detail |
|---|
protected final ReentrantLock[] locks
protected ReferenceQueue<Object> queue
protected Thread queueThread
protected LongConcurrentHashMap<Caches.WeakSoftRef.CacheItem> items
protected final boolean useWeakRef
| Constructor Detail |
|---|
public Caches.WeakSoftRef(Engine engine,
boolean useWeakRef,
boolean disableLocks)
| Method Detail |
|---|
protected void runRefQueue()
public <A> long put(A value,
Serializer<A> serializer)
Engine
put in interface Engineput in class EngineWrappervalue - records to be addedserializer - used to convert record into/from binary form
public <A> A get(long recid,
Serializer<A> serializer)
Engine
get in interface Engineget in class EngineWrapperrecid - (record identifier) under which record was persistedserializer - used to deserialize record from binary form
public <A> void update(long recid,
A value,
Serializer<A> serializer)
Engine
update in interface Engineupdate in class EngineWrapperrecid - (record identifier) under which record was persisted.value - new record value to be storedserializer - used to serialize record into binary form
public <A> void delete(long recid,
Serializer<A> serializer)
Engine
delete in interface Enginedelete in class EngineWrapperrecid - (record identifier) under which was record persistedserializer - which may be used in some circumstances to deserialize and store old object
public <A> boolean compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
EngineoldValue==expectedOldValue when old value is found in instance cacheoldValue using serializer and checking oldValue.equals(expectedOldValue)expectedOldValue using serializer and comparing binary array with already serialized oldValue
compareAndSwap in interface EnginecompareAndSwap in class EngineWrapperrecid - (record identifier) under which record was persisted.expectedOldValue - old value to be compared with existing recordnewValue - to be written if values are matchingserializer - used to serialize record into binary form
public void close()
EngineNullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.
close in interface Engineclose in class EngineWrapperpublic void rollback()
EngineUnsupportedOperationException.
rollback in interface Enginerollback in class EngineWrapperpublic void clearCache()
Engine
clearCache in interface EngineclearCache in class EngineWrapper
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||