|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mapdb.EngineWrapper
org.mapdb.Caches.HashTable
public static class Caches.HashTable
Fixed size cache which uses hash table. Is thread-safe and requires only minimal locking. Items are randomly removed and replaced by hash collisions.
This is simple, concurrent, small-overhead, random cache.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.mapdb.EngineWrapper |
|---|
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper |
| Field Summary | |
|---|---|
protected int |
cacheMaxSize
|
protected int |
cacheMaxSizeMask
|
protected long |
hashSalt
Salt added to keys before hashing, so it is harder to trigger hash collision attack. |
protected org.mapdb.Caches.HashTable.HashItem[] |
items
|
protected ReentrantLock[] |
locks
|
| 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.HashTable(Engine engine,
int cacheMaxSize,
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. |
|
|
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 org.mapdb.Caches.HashTable.HashItem[] items
protected final int cacheMaxSize
protected final int cacheMaxSizeMask
protected final long hashSalt
| Constructor Detail |
|---|
public Caches.HashTable(Engine engine,
int cacheMaxSize,
boolean disableLocks)
| Method Detail |
|---|
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> 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 <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 objectpublic 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 | ||||||||