database/bitcask
2022-05-21 16:03:59 -07:00
..
bitcask_search_test.go Fix breaking changes from upstream common package 2022-02-14 03:38:18 -08:00
bitcask_search.go Improve coverage: don't handle errors that won't exist. 2022-01-09 06:49:23 -08:00
bitcask_test.go Renames and Preallocations 2022-05-21 16:03:59 -07:00
bitcask.go Renames and Preallocations 2022-05-21 16:03:59 -07:00
errors.go Testing: yet another edge case bug fixed 2022-01-08 21:50:58 -08:00
keyvalue_test.go Fix breaking changes from upstream common package 2022-02-14 03:38:18 -08:00
keyvalue.go Renames and Preallocations 2022-05-21 16:03:59 -07:00
LICENSE License: MIT 2022-01-08 22:12:43 -08:00
README.md Semantics 2022-01-19 01:46:51 -08:00

bitcask

type DB

type DB struct {
}

DB is a mapper of a Filer and Searcher implementation using Bitcask.

func OpenDB

func OpenDB(path string) *DB

OpenDB will either open an existing set of bitcask datastores at the given directory, or it will create a new one.

func (*DB) Close

func (db *DB) Close(storeName string) error

Close is a simple shim for bitcask's Close function.

func (*DB) CloseAll

func (db *DB) CloseAll() error

CloseAll closes all bitcask datastores.

func (*DB) Init

func (db *DB) Init(storeName string) error

Init opens a bitcask store at the given path to be referenced by storeName.

func (*DB) Path

func (db *DB) Path() string

Path returns the base path where we store our bitcask "stores".

func (*DB) Sync

func (db *DB) Sync(storeName string) error

Sync is a simple shim for bitcask's Sync function.

func (*DB) SyncAll

func (db *DB) SyncAll() error

SyncAll syncs all bitcask datastores.

func (*DB) SyncAndCloseAll

func (db *DB) SyncAndCloseAll() error

SyncAndCloseAll implements the method from Keeper.

func (*DB) With

func (db *DB) With(storeName string) Store

With calls the given underlying bitcask instance.

type Key

type Key struct {
	database.Key
}

Key represents a key in a key/value store.

func (Key) Bytes

func (k Key) Bytes() []byte

Bytes returns the raw byte slice form of the Key.

func (Key) Equal

func (k Key) Equal(k2 Key) bool

Equal determines if two keys are equal.

func (Key) String

func (k Key) String() string

String returns the string slice form of the Key.

type KeyValue

type KeyValue struct {
	Key   Key
	Value Value
}

KeyValue represents a key and a value from a key/balue store.

type Store

type Store struct {
	*bitcask.Bitcask
	database.Searcher
}

Store is an implmentation of a Filer and a Searcher using Bitcask.

func (Store) AllKeys

func (c Store) AllKeys() (keys [][]byte)

AllKeys will return all keys in the database as a slice of byte slices.

func (Store) PrefixScan

func (c Store) PrefixScan(prefix string) ([]KeyValue, error)

PrefixScan will scan a Store for all keys that have a matching prefix of the given string and return a map of keys and values. (map[Key]Value)

func (c Store) Search(query string) ([]KeyValue, error)

Search will search for a given string within all values inside of a Store. Note, type casting will be necessary. (e.g: []byte or string)

func (Store) ValueExists

func (c Store) ValueExists(value []byte) (key []byte, ok bool)

ValueExists will check for the existence of a Value anywhere within the keyspace, returning the Key and true if found, or nil and false if not found.

type Value

type Value struct {
	database.Value
}

Value represents a value in a key/value store.

func (Value) Bytes

func (v Value) Bytes() []byte

Bytes returns the raw byte slice form of the Value.

func (Value) Equal

func (v Value) Equal(v2 Value) bool

Equal determines if two values are equal.

func (Value) String

func (v Value) String() string

String returns the string slice form of the Value.