Documentation ¶
Index ¶
- 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) Has(key []byte) (bool, error)
- func (w *Flushable) NewBatch() ethdb.Batch
- func (w *Flushable) NewIterator() ethdb.Iterator
- func (w *Flushable) NewIteratorWithPrefix(prefix []byte) ethdb.Iterator
- func (w *Flushable) NewIteratorWithStart(start []byte) ethdb.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 SyncedPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flushable ¶
type Flushable struct {
// contains filtered or unexported fields
}
Flushable is a ethdb.Database 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.KeyValueStore) *Flushable
Wrap underlying db. All the writes into the cache won't be written in parent until .Flush() is called.
func WrapWithDrop ¶
func WrapWithDrop(parent kvdb.KeyValueStore, drop func()) *Flushable
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) NewIterator ¶
NewIterator creates a binary-alphabetical iterator over the entire keyspace contained within the memory database.
func (*Flushable) NewIteratorWithPrefix ¶
NewIteratorWithPrefix creates a binary-alphabetical iterator over a subset of database content with a particular key prefix.
func (*Flushable) NewIteratorWithStart ¶
NewIteratorWithStart creates a binary-alphabetical iterator over a subset of database content 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.KeyValueStore, 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() 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.KeyValueStore
InitUnderlyingDb is UnderlyingDb getter. Makes underlying in lazy case.
type SyncedPool ¶
func NewSyncedPool ¶
func NewSyncedPool(producer kvdb.DbProducer) *SyncedPool
func (*SyncedPool) Flush ¶
func (p *SyncedPool) Flush(id []byte) error
func (*SyncedPool) GetDb ¶
func (p *SyncedPool) GetDb(name string) kvdb.KeyValueStore
func (*SyncedPool) IsFlushNeeded ¶
func (p *SyncedPool) IsFlushNeeded() bool
IsFlushNeeded returns true if it's recommended to flush data to disk