kv

package
v3.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: LGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator struct {
	IteratorBackend
}

Iterator is the storage iterator

type IteratorBackend

type IteratorBackend interface {
	Next() bool
	Key() []byte
	Value() []byte
	Error() error
	Release()
}

IteratorBackend is the storage iterator backend

type Storage

type Storage struct {
	StorageBackend
}

Storage is a kv database

func NewStorage

func NewStorage(path string, t StorageType) (*Storage, error)

NewStorage return the storage of the specify type

func (*Storage) NewIteratorByPrefix

func (s *Storage) NewIteratorByPrefix(prefix []byte) *Iterator

NewIteratorByPrefix returns a new iterator by prefix

type StorageBackend

type StorageBackend interface {
	Get(key []byte) ([]byte, error)
	Put(key []byte, value []byte) error
	Has(key []byte) (bool, error)
	Delete(key []byte) error
	Keys(prefix []byte) ([][]byte, error)
	KeysByRange(from []byte, to []byte, limit int) ([][]byte, error)
	BeginBatch() error
	CommitBatch() error
	Size() (int64, error)
	Close() error
	NewIteratorByPrefix(prefix []byte) any
}

StorageBackend is the storage backend interface

type StorageType

type StorageType uint8

StorageType is the type of storage, include leveldb and rocksdb

const (
	LevelDBStorage StorageType
)

Storage type constant

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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