Documentation ¶
Index ¶
- Constants
- type BadgerDatabase
- func (w *BadgerDatabase) Close()
- func (w *BadgerDatabase) Delete(key []byte) error
- func (w *BadgerDatabase) Get(key []byte) (res []byte, err error)
- func (w *BadgerDatabase) Has(key []byte) (bool, error)
- func (w *BadgerDatabase) NewBatch() Batch
- func (w *BadgerDatabase) Put(key []byte, value []byte) error
- type Batch
- type Database
- type Deleter
- type MemDatabase
- func (w *MemDatabase) Close()
- func (w *MemDatabase) Delete(key []byte) error
- func (w *MemDatabase) Get(key []byte) ([]byte, error)
- func (w *MemDatabase) Has(key []byte) (bool, error)
- func (w *MemDatabase) Keys() [][]byte
- func (w *MemDatabase) Len() int
- func (w *MemDatabase) NewBatch() Batch
- func (w *MemDatabase) Put(key []byte, value []byte) error
- type Putter
Constants ¶
const IdealBatchSize = 100 * 1024
IdealBatchSize was determined empirically. Code using batches should try to add this much data to the batch.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerDatabase ¶
type BadgerDatabase struct {
// contains filtered or unexported fields
}
BadgerDatabase is a kvbd.Database wrapper of *badger.DB
func NewBadgerDatabase ¶
func NewBadgerDatabase(db *badger.DB) *BadgerDatabase
NewBadgerDatabase wraps *badger.DB
func (*BadgerDatabase) Delete ¶
func (w *BadgerDatabase) Delete(key []byte) error
Delete removes key-value pair by key.
func (*BadgerDatabase) Get ¶
func (w *BadgerDatabase) Get(key []byte) (res []byte, err error)
Get returns key-value pair by key.
func (*BadgerDatabase) Has ¶
func (w *BadgerDatabase) Has(key []byte) (bool, error)
Has checks if key is in the db.
func (*BadgerDatabase) NewBatch ¶
func (w *BadgerDatabase) NewBatch() Batch
NewBatch creates new batch.
type Batch ¶
type Batch interface { Putter Deleter ValueSize() int // amount of data in the batch Write() error // Reset resets the batch for reuse Reset() }
Batch is a write-only database that commits changes to its host database when Write is called. Batch cannot be used concurrently.
func NewTableBatch ¶
NewTableBatch returns a Batch object which prefixes all keys with a given string.
type Database ¶
type Database interface { Putter Deleter Get(key []byte) ([]byte, error) Has(key []byte) (bool, error) Close() NewBatch() Batch }
Database wraps all database operations. All methods are safe for concurrent use.
type Deleter ¶
Deleter wraps the database delete operation supported by both batches and regular databases.
type MemDatabase ¶
type MemDatabase struct {
// contains filtered or unexported fields
}
MemDatabase is a kvbd.Database wrapper of map[string][]byte Do not use for any production it does not get persisted
func (*MemDatabase) Delete ¶
func (w *MemDatabase) Delete(key []byte) error
Delete removes key-value pair by key.
func (*MemDatabase) Get ¶
func (w *MemDatabase) Get(key []byte) ([]byte, error)
Get returns key-value pair by key.
func (*MemDatabase) Has ¶
func (w *MemDatabase) Has(key []byte) (bool, error)
Has checks if key is in the db.
func (*MemDatabase) Keys ¶
func (w *MemDatabase) Keys() [][]byte
Keys returns slice of keys in the db.
func (*MemDatabase) Len ¶
func (w *MemDatabase) Len() int
Len returns count of key-values pairs in the db.