bitcask

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 17 Imported by: 3

README

bitcask

var (
	ErrUnknownAction = errors.New("unknown action")
	ErrBogusStore    = errors.New("bogus store backend")
	ErrStoreExists   = errors.New("store name already exists")
	ErrNoStores      = errors.New("no stores initialized")
)
func SetDefaultBitcaskOptions
func SetDefaultBitcaskOptions(bitcaskopts ...bitcask.Option)

SetDefaultBitcaskOptions options will set the options used for all subsequent bitcask stores that are initialized.

func WithMaxDatafileSize
func WithMaxDatafileSize(size int) bitcask.Option

WithMaxDatafileSize is a shim for bitcask's WithMaxDataFileSize function.

func WithMaxKeySize
func WithMaxKeySize(size uint32) bitcask.Option

WithMaxKeySize is a shim for bitcask's WithMaxKeySize function.

func WithMaxValueSize
func WithMaxValueSize(size uint64) bitcask.Option

WithMaxValueSize is a shim for bitcask's WithMaxValueSize function.

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) AllStores
func (db *DB) AllStores() map[string]database.Filer

AllStores returns a map of the names of all bitcask datastores and the corresponding Filers.

func (*DB) BackupAll
func (db *DB) BackupAll(archivePath string) (models.Backup, error)
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) Destroy
func (db *DB) Destroy(storeName string) error

Destroy will remove the bitcask store and all data associated with it.

func (*DB) Discover
func (db *DB) Discover() ([]string, error)

Discover will discover and initialize all existing bitcask stores at the path opened by [OpenDB].

func (*DB) Init
func (db *DB) Init(storeName string, opts ...any) error

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

func (*DB) Meta
func (db *DB) Meta() models.Metadata

Meta returns the [models.Metadata] implementation of the bitcask keeper.

func (*DB) Path
func (db *DB) Path() string

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

func (*DB) RestoreAll
func (db *DB) RestoreAll(archivePath string) error
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 to sync and close all bitcask stores.

func (*DB) Type
func (db *DB) Type() string

Type returns the type of keeper, in this case "bitcask". This is in order to implement [database.Keeper].

func (*DB) With
func (db *DB) With(storeName string) database.Filer

With calls the given underlying bitcask instance.

func (*DB) WithNew
func (db *DB) WithNew(storeName string, opts ...any) database.Filer

WithNew calls the given underlying bitcask instance, if it doesn't exist, it creates it.

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

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

func (*Store) Backend
func (s *Store) Backend() any

Backend returns the underlying bitcask instance.

func (*Store) Close
func (s *Store) Close() error

Close is a wrapper around the bitcask Close function.

func (*Store) Get
func (s *Store) Get(key []byte) ([]byte, error)

Get is a wrapper around the bitcask Get function for error regularization.

func (*Store) Keys
func (s *Store) Keys() (keys [][]byte)

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

func (*Store) PrefixScan
func (s *Store) PrefixScan(prefix string) (<-chan kv.KeyValue, chan 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 (s *Store) Search(query string) (<-chan kv.KeyValue, chan 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 (s *Store) ValueExists(value []byte) (key []byte, ok bool)

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


Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownAction = errors.New("unknown action")
	ErrBogusStore    = errors.New("bogus store backend")
	ErrStoreExists   = errors.New("store name already exists")
	ErrNoStores      = errors.New("no stores initialized")
)
View Source
var ErrBadOpt = errors.New("invalid bitcask options")

Functions

func SetDefaultBitcaskOptions

func SetDefaultBitcaskOptions(bitcaskopts ...bitcask.Option)

SetDefaultBitcaskOptions options will set the options used for all subsequent bitcask stores that are initialized.

func WithMaxDatafileSize

func WithMaxDatafileSize(size int) bitcask.Option

WithMaxDatafileSize is a shim for bitcask's WithMaxDataFileSize function.

func WithMaxKeySize

func WithMaxKeySize(size uint32) bitcask.Option

WithMaxKeySize is a shim for bitcask's WithMaxKeySize function.

func WithMaxValueSize

func WithMaxValueSize(size uint64) bitcask.Option

WithMaxValueSize is a shim for bitcask's WithMaxValueSize function.

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) AllStores

func (db *DB) AllStores() map[string]database.Filer

AllStores returns a map of the names of all bitcask datastores and the corresponding Filers.

func (*DB) BackupAll added in v0.4.2

func (db *DB) BackupAll(archivePath string) (models.Backup, error)

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) Destroy added in v0.4.2

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

Destroy will remove the bitcask store and all data associated with it.

func (*DB) Discover

func (db *DB) Discover() ([]string, error)

Discover will discover and initialize all existing bitcask stores at the path opened by OpenDB.

func (*DB) Init

func (db *DB) Init(storeName string, opts ...any) error

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

func (*DB) Meta added in v0.4.1

func (db *DB) Meta() models.Metadata

Meta returns the models.Metadata implementation of the bitcask keeper.

func (*DB) Path

func (db *DB) Path() string

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

func (*DB) RestoreAll added in v0.4.2

func (db *DB) RestoreAll(archivePath string) error

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 pogreb datastores. TODO: investigate locking here, right now if we try to hold a lock during a backup we'll hang :^)

func (*DB) SyncAndCloseAll

func (db *DB) SyncAndCloseAll() error

SyncAndCloseAll implements the method from Keeper to sync and close all bitcask stores.

func (*DB) Type added in v0.4.1

func (db *DB) Type() string

Type returns the type of keeper, in this case "bitcask". This is in order to implement database.Keeper.

func (*DB) With

func (db *DB) With(storeName string) database.Filer

With calls the given underlying bitcask instance.

func (*DB) WithNew

func (db *DB) WithNew(storeName string, opts ...any) database.Filer

WithNew calls the given underlying bitcask instance, if it doesn't exist, it creates it.

type Store

type Store struct {
	*bitcask.Bitcask
	database.Searcher
	// contains filtered or unexported fields
}

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

func (*Store) Backend

func (s *Store) Backend() any

Backend returns the underlying bitcask instance.

func (*Store) Close added in v0.4.2

func (s *Store) Close() error

Close is a wrapper around the bitcask Close function.

func (*Store) Get added in v0.4.2

func (s *Store) Get(key []byte) ([]byte, error)

Get is a wrapper around the bitcask Get function for error regularization.

func (*Store) Keys

func (s *Store) Keys() (keys [][]byte)

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

func (*Store) PrefixScan

func (s *Store) PrefixScan(prefix string) (<-chan kv.KeyValue, chan 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 (s *Store) Search(query string) (<-chan kv.KeyValue, chan 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 (s *Store) ValueExists(value []byte) (key []byte, ok bool)

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

Jump to

Keyboard shortcuts

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