Documentation ¶
Overview ¶
Package kv defines a standard interface for key-value storage and iteration. It supports persistent storage using LevelDB and BadgerDB. It also supports non-persistent storage using concurrent-safe in-memory maps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrKeyNotFound is returned when there is no value associated with a key. ErrKeyNotFound = db.ErrKeyNotFound // ErrEmptyKey is returned when a key is the empty string. ErrEmptyKey = db.ErrEmptyKey // ErrIndexOutOfRange is returned when the iterator index is less than zero, // or, greater than or equal to the size of the iterator. ErrIndexOutOfRange = db.ErrIndexOutOfRange )
View Source
var ( // BinaryCodec is a binary codec that marshals and unmarshals values using // the standard Golang Binary marshalers. For more information, see // https://golang.org/pkg/encoding. BinaryCodec = codec.BinaryCodec // JSONCodec is a json codec that marshals and unmarshals values using the // standard Golang JSON marshalers. For more information, see // https://golang.org/pkg/encoding/json. JSONCodec = codec.JSONCodec // GobCodec is a gob codec that encodes and decodes values using gob. For // more information, see https://golang.org/pkg/encoding/gob. GobCodec = codec.GobCodec )
Codecs
View Source
var ( // NewMemDB returns a key-value database that is implemented in-memory. This // implementation is fast, but does not store data on-disk. It is safe for // concurrent use. NewMemDB = memdb.New // NewBadgerDB returns a key-value database that is implemented using // BadgerDB. For more information, see https://github.com/dgraph-io/badger. NewBadgerDB = badgerdb.New // NewLevelDB returns a key-value database that is implemented using // levelDB. For more information, see https://github.com/syndtr/goleveldb. NewLevelDB = leveldb.New // NewTable returns a new table basing on the given DB and codec. NewTable = db.NewTable )
View Source
var ( // NewLRUTable wraps a given Table and creates a Table which has lru cache. NewLRUTable = lru.NewLruTable // NewTTLCache wraps a given DB and creates a time-to-live DB. It will // automatically prune the data in the db until the context expires. NewTTLCache = ttl.New )
Functions ¶
This section is empty.
Types ¶
type DB ¶ added in v1.0.0
A DB is a low-level interface for storing and iterating over key/value pairs.
Click to show internal directories.
Click to hide internal directories.