Documentation ¶
Index ¶
- Constants
- type Flushable
- func (w *Flushable) Close() error
- func (w *Flushable) Compact(start []byte, limit []byte) error
- func (w *Flushable) Delete(key []byte) error
- func (w *Flushable) Drop()
- func (w *Flushable) DropNotFlushed()
- func (w *Flushable) Flush() error
- func (w *Flushable) Get(key []byte) ([]byte, error)
- func (w *Flushable) GetSnapshot() (kvdb.Snapshot, error)
- func (w *Flushable) Has(key []byte) (bool, error)
- func (w *Flushable) NewBatch() kvdb.Batch
- func (w *Flushable) NewIterator(prefix []byte, start []byte) kvdb.Iterator
- func (w *Flushable) NotFlushedPairs() int
- func (w *Flushable) NotFlushedSizeEst() int
- func (w *Flushable) Put(key []byte, value []byte) error
- func (w *Flushable) Stat(property string) (string, error)
- type LazyFlushable
- type Snapshot
- type SyncedPool
- func (p *SyncedPool) Close() error
- func (p *SyncedPool) Flush(id []byte) error
- func (p *SyncedPool) GetUnderlying(name string) (kvdb.ReadonlyStore, error)
- func (p *SyncedPool) Initialize(dbNames []string) error
- func (p *SyncedPool) NotFlushedSizeEst() int
- func (p *SyncedPool) OpenDB(name string) (kvdb.DropableStore, error)
Constants ¶
const ( DirtyPrefix = 0xde CleanPrefix = 0x00 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flushable ¶
type Flushable struct {
// contains filtered or unexported fields
}
Flushable is a kvdb.Store wrapper around any Database. On reading, it looks in memory cache first. If not found, it looks in a parent DB. On writing, it writes only in cache. To flush the cache into parent DB, call Flush().
func Wrap ¶
func Wrap(parent kvdb.DropableStore) *Flushable
Wrap underlying db. All the writes into the cache won't be written in parent until .Flush() is called.
func WrapWithDrop ¶
WrapWithDrop is the same as Wrap, but defines onDrop callback.
func (*Flushable) Delete ¶
Delete removes key-value pair by key. In parent DB, key won't be deleted until .Flush() is called.
func (*Flushable) DropNotFlushed ¶
func (w *Flushable) DropNotFlushed()
DropNotFlushed drops all the not flushed keys. After this call, the state of parent DB is identical to the state of this DB.
func (*Flushable) GetSnapshot ¶
GetSnapshot returns a latest snapshot of the underlying DB. A snapshot is a frozen snapshot of a DB state at a particular point in time. The content of snapshot are guaranteed to be consistent.
The snapshot must be released after use, by calling Release method.
func (*Flushable) NewIterator ¶
NewIterator creates a binary-alphabetical iterator over a subset of database content with a particular key prefix, starting at a particular initial key (or after, if it does not exist).
func (*Flushable) NotFlushedPairs ¶
NotFlushedPairs returns num of not flushed keys, including deleted keys.
func (*Flushable) NotFlushedSizeEst ¶
NotFlushedSizeEst returns estimation of not flushed data, including deleted keys.
type LazyFlushable ¶
type LazyFlushable struct { *Flushable // contains filtered or unexported fields }
LazyFlushable is a Flushable with delayed DB producer
func NewLazy ¶
func NewLazy(producer func() (kvdb.DropableStore, error), drop func()) *LazyFlushable
NewLazy makes flushable with real db producer. Real db won't be produced until first .Flush() is called. All the writes into the cache won't be written in parent until .Flush() is called.
func (*LazyFlushable) Flush ¶
func (w *LazyFlushable) Flush() (err error)
Flush current cache into parent DB. Real db won't be produced until first .Flush() is called.
func (*LazyFlushable) InitUnderlyingDb ¶
func (w *LazyFlushable) InitUnderlyingDb() (kvdb.Store, error)
InitUnderlyingDb is UnderlyingDb getter. Makes underlying in lazy case.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is a DB snapshot.
func (*Snapshot) NewIterator ¶
NewIterator creates a binary-alphabetical iterator over a subset of database content with a particular key prefix, starting at a particular initial key (or after, if it does not exist).
type SyncedPool ¶
func NewSyncedPool ¶
func NewSyncedPool(producer kvdb.DBProducer, flushIDKey []byte) *SyncedPool
func (*SyncedPool) Close ¶
func (p *SyncedPool) Close() error
func (*SyncedPool) Flush ¶
func (p *SyncedPool) Flush(id []byte) error
func (*SyncedPool) GetUnderlying ¶
func (p *SyncedPool) GetUnderlying(name string) (kvdb.ReadonlyStore, error)
func (*SyncedPool) Initialize ¶
func (p *SyncedPool) Initialize(dbNames []string) error
func (*SyncedPool) NotFlushedSizeEst ¶
func (p *SyncedPool) NotFlushedSizeEst() int
NotFlushedSizeEst returns a total size of not flushed key pairs
func (*SyncedPool) OpenDB ¶
func (p *SyncedPool) OpenDB(name string) (kvdb.DropableStore, error)