Documentation ¶
Overview ¶
Package kv contains a generic interface for key-value databases with support for batch writes. All operations are safe for concurrent use, atomic and synchronously persistent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IncrementKey ¶
IncrementKey returns the lexicographically first DB key which is greater than all keys prefixed by "prefix". Following the Range.Limit convention, IncrementKey may return nil, a sentinel value that is to be interpreted as greater than all keys.
Types ¶
type DB ¶
type DB interface { Get(key []byte) ([]byte, error) Put(key, value []byte) error Delete(key []byte) error NewBatch() Batch Write(Batch) error NewIterator(*Range) Iterator Close() error ErrNotFound() error }
DB is an abstract ordered key-value store. All operations are assumed to be synchronous, atomic and linearizable. This includes the following guarantee: After Put(k, v) has returned, and as long as no other Put(k, ?) has been called happened, Get(k) MUST return always v, regardless of whether the process or the entire system has been reset in the meantime or very little time has passed. To amortize the overhead of synchronous writes, DB offers batch operations: Write(...) performs a series of Put-s atomically (and possibly almost as fast as a single Put).
type Iterator ¶
type Iterator interface { Key() []byte Value() []byte First() bool Next() bool Last() bool Release() Error() error }
Iterator is an abstract pointer to a DB entry. It must be valid to call Error() after release. The boolean return values indicate whether the requested entry exists.