org.mapdb
Class StoreCached
- java.lang.Object
-
- org.mapdb.Store
-
- org.mapdb.StoreDirect
-
- org.mapdb.StoreCached
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable, Engine
- Direct Known Subclasses:
- StoreWAL
public class StoreCached extends StoreDirect
ExtendsStoreDirectwith Write Cache
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.mapdb.StoreDirect
StoreDirect.Snapshot
-
Nested classes/interfaces inherited from class org.mapdb.Store
Store.Cache, Store.LongLongMap, Store.LongObjectMap<V>, Store.LongObjectObjectMap<V1,V2>, Store.LongQueue, Store.MemoryBarrierLessLock, Store.ReadWriteSingleLock
-
Nested classes/interfaces inherited from interface org.mapdb.Engine
Engine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper
-
-
Field Summary
-
Fields inherited from class org.mapdb.Store
LOCKING_STRATEGY_NOLOCK, LOCKING_STRATEGY_READWRITELOCK, LOCKING_STRATEGY_WRITELOCK, NOLOCK
-
Fields inherited from interface org.mapdb.Engine
CLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK
-
-
Constructor Summary
Constructors Constructor and Description StoreCached(java.lang.String fileName)StoreCached(java.lang.String fileName, Volume.VolumeFactory volumeFactory, Store.Cache cache, int lockScale, int lockingStrategy, boolean checksum, boolean compress, byte[] password, boolean readonly, boolean snapshotEnable, boolean fileLockDisable, DataIO.HeartbeatFileLock fileLockHeartbeat, java.util.concurrent.ScheduledExecutorService executor, long startSize, long sizeIncrement, boolean recidReuseDisable, long executorScheduledRate, int writeQueueSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description <A> booleancompareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)Updates existing record in atomic (Compare And Swap) manner.<A> longput(A value, Serializer<A> serializer)Insert new record.<A> voidupdate(long recid, A value, Serializer<A> serializer)Update existing record with new value.-
Methods inherited from class org.mapdb.StoreDirect
backup, backupRestore, canRollback, clearCache, close, commit, compact, fileLoad, getCurrSize, getFreeSize, init, preallocate, rollback, snapshot
-
Methods inherited from class org.mapdb.Store
canSnapshot, delete, forDB, forEngine, get, getWrappedEngine, isClosed, isReadOnly, metricsCollect
-
-
-
-
Constructor Detail
-
StoreCached
public StoreCached(java.lang.String fileName, Volume.VolumeFactory volumeFactory, Store.Cache cache, int lockScale, int lockingStrategy, boolean checksum, boolean compress, byte[] password, boolean readonly, boolean snapshotEnable, boolean fileLockDisable, DataIO.HeartbeatFileLock fileLockHeartbeat, java.util.concurrent.ScheduledExecutorService executor, long startSize, long sizeIncrement, boolean recidReuseDisable, long executorScheduledRate, int writeQueueSize)
-
StoreCached
public StoreCached(java.lang.String fileName)
-
-
Method Detail
-
put
public <A> long put(A value, Serializer<A> serializer)Description copied from interface:EngineInsert new record.- Specified by:
putin interfaceEngine- Overrides:
putin classStoreDirect- Parameters:
value- records to be addedserializer- used to convert record into/from binary form- Returns:
- recid (record identifier) under which record is stored.
-
update
public <A> void update(long recid, A value, Serializer<A> serializer)Description copied from interface:EngineUpdate existing record with new value.
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
-
compareAndSwap
public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)Description copied from interface:EngineUpdates existing record in atomic (Compare And Swap) manner. Value is modified only if old value matches expected value. There are three ways to match values, MapDB may use any of them:
- Equality check
oldValue==expectedOldValuewhen old value is found in instance cache - Deserializing
oldValueusingserializerand checkingoldValue.equals(expectedOldValue) - Serializing
expectedOldValueusingserializerand comparing binary array with already serializedoldValue
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
- Specified by:
compareAndSwapin interfaceEngine- Overrides:
compareAndSwapin classStore- Parameters:
recid- (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- Returns:
- true if values matched and newValue was written
- Equality check
-
-
DataMelt 3.0 © DataMelt by jWork.ORG