Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("kvndb: key not found") ErrTooMuchHistory = errors.New("kvndb: do you really need that much history") ErrSnapshotNotFound = errors.New("kvndb: there are no loadable snapshots, data was reset") ErrAlreadyClosed = errors.New("kvndb: operations on closed datastore are not possible") ErrBadSnapshot = errors.New("kvndb: checksum mismatch likely snapshot corrupted") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Put adds or updates entry for given key. Put(key, value []byte) error // Get returns value for given key, ErrKeyNotFound if key // does not exist. Get(key []byte) ([]byte, error) // Delete removes entry for given key. Delete(key []byte) error // Size returns the number of currently stored entries. Size() uint64 // Keys returns a channel that will iterate over keys of all // entries.This operation is synchronous, which means all // other operations will be blocked until all values are read. // You MUST read all values until the channel is closed. Best // to use `range`. Keys() (<-chan []byte, error) // KeysAndValues returns a channel that will iterate // over all keys and values of all entries. This operation // is synchronous, which means all other operations will be // blocked until all values are read. You MUST read all values // until the channel is closed. Best to use `range`. KeysAndValues() (<-chan *Tuple, error) // Save will write a snapshot of data into provided // directory path. If snapshot successful it will clean up // keeping only `hist` number of snapshots. This operation // is synchronous, which means all other operations will be // blocked until it is done. `hist` value of 0 will only // save current copy. Value of 1 will keep current and previous. Save(dir string, hist uint) error // Load will load data from snapshot. It will replace any // current data completely (not merge/update). It will // always load latest found snapshot version. This operation // is synchronous, which means all other operations will be // blocked until it is done. Load(dir string) error // Wait will block until a previously started operation frees // mutex. If datastore was already closed, it is a no-op. Wait() // Close reset the data store and set status to closed. After // this no operations can be done. Close() error }
Click to show internal directories.
Click to hide internal directories.