Documentation ¶
Index ¶
- Variables
- type DB
- func (db *DB) Close() error
- func (db *DB) CompactTo(w io.Writer) (int, map[string]FileRef, error)
- func (db *DB) Count() int
- func (db *DB) Delete(k []byte) error
- func (db *DB) FilePath() string
- func (db *DB) ForEachKey(callback func(k []byte) (stop bool))
- func (db *DB) Get(k []byte) ([]byte, error)
- func (db *DB) KeyExists(k []byte) bool
- func (db *DB) KeyFileRef(k []byte) (FileRef, bool)
- func (db *DB) Lock()
- func (db *DB) Put(k, v []byte) error
- func (db *DB) Sync() error
- func (db *DB) Unlock()
- func (db *DB) WriteTo(w io.Writer) (int64, error)
- type FileRef
- type Format
- type WriteOp
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrKeyEmpty = errors.New("key is empty") ErrKeyAlreadyExists = errors.New("key already exists") ErrUnknownWriteOp = errors.New("unknown write operation") )
var DefaultFormat = &Format{
PutKey: '-',
PutKeyValue: '=',
Delete: '!',
KeyPrefix: ' ',
ValuePrefix: ' ',
RowEnd: '\n',
}
TextFileFormat with default values.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewDB ¶
Instanciates a new DB. Opens underlying file handles for the given path (for reading and writing data to a file on disk) and extract initial data.
func (*DB) Delete ¶
Removes a key from the database. Further attempts to access this key will result in a ErrKeyNotFound.
func (*DB) ForEachKey ¶
Iterates over all the keys in the database. The callback may return true to exit the loop. Keys are not ordered.
func (*DB) KeyFileRef ¶
Get the corresponding offset and size of a row on file. If the key file ref is not found, the key does not exist.
type FileRef ¶
Reference to a specific range of bytes in a file. Used to map a row to its location on file.
type Format ¶
type Format struct { PutKey byte // Default: '-' PutKeyValue byte // Default: '=' Delete byte // Default: '!' KeyPrefix byte // Default: ' ' (whitespace) ValuePrefix byte // Default: ' ' (whitespace) RowEnd byte // Default: '\n' (line-break) SizeStart byte // Default: '(' SizeSeparator byte // Default: '|' SizeEnd byte // Default: ')' SizeBase int // Default: 10 (decimal) }
Holds characters used for encoding and decoding row data.