package kv
import "go.dedis.ch/dela/core/store/kv"
Package kv defines the abstraction for a key/value database.
The package also implements a default database implementation that is using bbolt as the engine (https://github.com/etcd-io/bbolt).
Documentation Last Review: 08.10.2020
Index ¶
Types ¶
type Bucket ¶
type Bucket interface { // Get reads the key from the bucket and returns the value, or nil if the // key does not exist. Get(key []byte) []byte // Set assigns the value to the provided key. Set(key, value []byte) error // Delete the key from the bucket. Delete(key []byte) error // ForEach iterates over all the items in the bucket in an unspecified order. // The iteration stops when the callback returns an error. ForEach(func(k, v []byte) error) error // Scan iterates over every key that matches the prefix in an order // determined by the implementation. The iteration stops when the callback // returns an error. Scan(prefix []byte, fn func(k, v []byte) error) error }
Bucket is a general interface to operate on a database bucket.
type DB ¶
type DB interface { // View executes the provided read-only transaction in the context of the // database. View(fn func(ReadableTx) error) error // Update executes the provided writable transaction in the context of the // database. Update(fn func(WritableTx) error) error // Close closes the database and free the resources. Close() error }
DB is a general interface to operate over a key/value database.
func New ¶
New opens a new database to the given file.
type ReadableTx ¶
type ReadableTx interface { // GetBucket returns the bucket of the given name if it exists, otherwise it // returns nil. GetBucket(name []byte) Bucket }
ReadableTx allows one to perform read-only atomic operations on the database.
type WritableTx ¶
type WritableTx interface { store.Transaction ReadableTx // GetBucketOrCreate returns the bucket of the given name if it exists, or // it creates it. GetBucketOrCreate(name []byte) (Bucket, error) }
WritableTx allows one to perform atomic operations on the database.
Source Files ¶
default.go kv.go
Directories ¶
Path | Synopsis |
---|---|
core/store/kv/controller | Package controller implements a CLI controller for the key/value database. |
- Version
- v0.1.0 (latest)
- Published
- Apr 10, 2024
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 1 month ago –
Tools for package owners.