flushable

package
v1.0.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 13 Imported by: 1

Documentation

Index

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) Close

func (w *Flushable) Close() error

Close leaves underlying database.

func (*Flushable) Compact

func (w *Flushable) Compact(start []byte, limit []byte) error

Compact flattens the underlying data store for the given key range.

func (*Flushable) Delete

func (w *Flushable) Delete(key []byte) error

Delete removes key-value pair by key. In parent DB, key won't be deleted until .Flush() is called.

func (*Flushable) Drop

func (w *Flushable) Drop()

Drop whole database.

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) Flush

func (w *Flushable) Flush() error

Flush current cache into parent DB.

func (*Flushable) Get

func (w *Flushable) Get(key []byte) ([]byte, error)

Get returns key-value pair by key. Looks in cache first, then - in DB.

func (*Flushable) Has

func (w *Flushable) Has(key []byte) (bool, error)

Has checks if key is in the exists. Looks in cache first, then - in DB.

func (*Flushable) NewBatch

func (w *Flushable) NewBatch() ethdb.Batch

NewBatch creates new batch.

func (*Flushable) NewIterator

func (w *Flushable) NewIterator(prefix []byte, start []byte) ethdb.Iterator

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

func (w *Flushable) NotFlushedPairs() int

NotFlushedPairs returns num of not flushed keys, including deleted keys.

func (*Flushable) NotFlushedSizeEst

func (w *Flushable) NotFlushedSizeEst() int

NotFlushedSizeEst returns estimation of not flushed data, including deleted keys.

func (*Flushable) Put

func (w *Flushable) Put(key []byte, value []byte) error

Put puts key-value pair into the cache.

func (*Flushable) Stat

func (w *Flushable) Stat(property string) (string, error)

Stat returns a particular internal stat of the database.

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

type SyncedPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL