Documentation ¶
Index ¶
- type BadgerDBHandle
- func (h *BadgerDBHandle) Close() error
- func (h *BadgerDBHandle) CompactRange(start, limit []byte) error
- func (h *BadgerDBHandle) Delete(key []byte) error
- func (h *BadgerDBHandle) Get(key []byte) ([]byte, error)
- func (h *BadgerDBHandle) GetDbType() string
- func (h *BadgerDBHandle) GetKeys(keys [][]byte) ([][]byte, error)
- func (h *BadgerDBHandle) GetWriteBatchSize() uint64
- func (h *BadgerDBHandle) Has(key []byte) (bool, error)
- func (h *BadgerDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
- func (h *BadgerDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)
- func (h *BadgerDBHandle) Put(key []byte, value []byte) error
- func (h *BadgerDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
- type BadgerDbConfig
- type Iterator
- type NewBadgerDBOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerDBHandle ¶
type BadgerDBHandle struct {
// contains filtered or unexported fields
}
BadgerDBHandle encapsulated handle to badgerDB
func NewBadgerDBHandle ¶
func NewBadgerDBHandle(input *NewBadgerDBOptions) *BadgerDBHandle
NewBadgerDBHandle use NewBadgerDBOptions to build BadgerDBHandle @param *NewBadgerDBOptions config option @return *BadgerDBHandle
func (*BadgerDBHandle) Close ¶
func (h *BadgerDBHandle) Close() error
Close closes the badgerdb @return error
func (*BadgerDBHandle) CompactRange ¶
func (h *BadgerDBHandle) CompactRange(start, limit []byte) error
CompactRange compacts the underlying DB for the given key range. @param []byte start @param []byte limit @return error (default nil)
func (*BadgerDBHandle) Delete ¶
func (h *BadgerDBHandle) Delete(key []byte) error
Delete deletes the given key @param []byte key @return error
func (*BadgerDBHandle) Get ¶
func (h *BadgerDBHandle) Get(key []byte) ([]byte, error)
Get returns the value for the given key, or returns nil if none exists @param []byte key @return []byte @return error
func (*BadgerDBHandle) GetDbType ¶
func (h *BadgerDBHandle) GetDbType() string
GetDbType returns db type , "leveldb"(default) @return string
func (*BadgerDBHandle) GetKeys ¶
func (h *BadgerDBHandle) GetKeys(keys [][]byte) ([][]byte, error)
GetKeys returns the value for the given key @param [][]byte multi keys @return [][]byte multi values @return error
func (*BadgerDBHandle) GetWriteBatchSize ¶
func (h *BadgerDBHandle) GetWriteBatchSize() uint64
GetWriteBatchSize returns write batch size @return uint64
func (*BadgerDBHandle) Has ¶
func (h *BadgerDBHandle) Has(key []byte) (bool, error)
Has return true if the given key exist, or return false if none exists @param []byte key @return bool @return error
func (*BadgerDBHandle) NewIteratorWithPrefix ¶
func (h *BadgerDBHandle) NewIteratorWithPrefix(prefix []byte) (protocol.Iterator, error)
NewIteratorWithPrefix returns an iterator that contains all the key-values with given prefix @param []byte prefix @return protocol.Iterator @return error
func (*BadgerDBHandle) NewIteratorWithRange ¶
func (h *BadgerDBHandle) NewIteratorWithRange(startKey []byte, limitKey []byte) (protocol.Iterator, error)
NewIteratorWithRange returns an iterator that contains all the key-values between given key ranges start is included in the results and limit is excluded. @param []byte startKey @param []byte limitKey @return protocol.Iterator @return error
func (*BadgerDBHandle) Put ¶
func (h *BadgerDBHandle) Put(key []byte, value []byte) error
Put saves the key-values @param []byte key @param []byte value @return error
func (*BadgerDBHandle) WriteBatch ¶
func (h *BadgerDBHandle) WriteBatch(batch protocol.StoreBatcher, sync bool) error
WriteBatch writes a batch in an atomic operation @param protocol.StoreBatcher @param bool sync @return error
type BadgerDbConfig ¶
type BadgerDbConfig struct { StorePath string `mapstructure:"store_path"` Compression uint8 `mapstructure:"compression"` ValueThreshold int64 `mapstructure:"value_threshold"` WriteBatchSize uint64 `mapstructure:"write_batch_size"` }
BadgerDbConfig badger db configuration
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator encapsulated badger-db iterator
func NewIterator ¶
func NewIterator(db *badger.DB, opts badger.IteratorOptions, start []byte, end []byte, encryptor crypto.SymmetricKey) *Iterator
NewIterator construct Iterator @param *badger.DB db instance @param badger.IteratorOptions opt @param []byte start @param []byte end @return *Iterator
func (*Iterator) Error ¶
Error return error ,nil(default) @return error
func (*Iterator) Next ¶
Next check iterator whether it has next element @return bool
type NewBadgerDBOptions ¶
type NewBadgerDBOptions struct { Config *BadgerDbConfig Logger protocol.Logger Encryptor crypto.SymmetricKey ChainId string DbFolder string }
NewBadgerDBOptions used to build BadgerDBHandle