Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- func (db *DB) Begin(writable bool) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) Delete(key []byte) error
- func (db *DB) Get(key []byte) ([]byte, error)
- func (db *DB) Put(key, value []byte) error
- func (db *DB) Update(fn func(tx *Tx) error) error
- func (db *DB) View(fn func(tx *Tx) error) error
- type Option
- type Tx
Constants ¶
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
Variables ¶
var ( ErrEmptyKey = errors.New("empty key") ErrKeyTooLarge = errors.New("key size is too large") ErrValueTooLarge = errors.New("value size is too large") ErrInvalidKey = errors.New("invalid key") ErrInvalidTTL = errors.New("invalid ttl") ErrExpiredKey = errors.New("key has expired") ErrTxClosed = errors.New("tx closed") ErrDatabaseClosed = errors.New("database closed") ErrTxNotWritable = errors.New("tx not writable") )
var ( ErrInvalidSegment = errors.New("invalid segment") ErrInvalidSegmentVersion = errors.New("invalid segment version") ErrSegmentNotWritable = errors.New("segment not writable") ErrSegmentTooLarge = errors.New("segment too large") ErrKeyNotFound = errors.New("key not found") )
var (
ErrInvalidRecord = errors.New("invalid record")
)
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) Update ¶
Update executes a function within a managed read/write transaction. The transaction has been committed when no error is returned. In the event that an error is returned, the transaction will be rolled back. When a non-nil error is returned from the function, the transaction will be rolled back and the that error will be return to the caller of Update().
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a transaction on the database. This transaction can either be read-only or read/write. Read-only transactions can be used for retrieving values for keys and iterating through keys and values. Read/write transactions can set and delete keys.
All transactions must be committed or rolled-back when done.