bitcask

package
v0.0.0-...-7e12d11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2022 License: MIT, MIT Imports: 6 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

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, bitcaskopts ...bitcask.Option) 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
	// contains filtered or unexported fields
}

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 (Store) Search

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
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL