pogreb

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownAction = errors.New("unknown action")
	ErrBogusStore    = errors.New("bogus store backend")
	ErrBadOptions    = errors.New("invalid pogreb options")
	ErrStoreExists   = errors.New("store name already exists")
	ErrNoStores      = errors.New("no stores initialized")
)
View Source
var OptionAllowRecovery = func(opts *WrappedOptions) {
	opts.AllowRecovery = true
}

Functions

func SetDefaultPogrebOptions

func SetDefaultPogrebOptions(pogrebopts ...any)

SetDefaultPogrebOptions options will set the options used for all subsequent pogreb stores that are initialized.

Types

type DB

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

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

func OpenDB

func OpenDB(path string) *DB

OpenDB will either open an existing set of pogreb 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 pogreb datastores and the corresponding Filers.

func (*DB) Close

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

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

func (*DB) CloseAll

func (db *DB) CloseAll() error

CloseAll closes all pogreb datastores.

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 pogreb 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 pogreb "stores".

func (*DB) Sync

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

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

func (*DB) SyncAll

func (db *DB) SyncAll() error

SyncAll syncs all pogreb datastores.

func (*DB) SyncAndCloseAll

func (db *DB) SyncAndCloseAll() error

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

func (*DB) With

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

With calls the given underlying pogreb instance.

func (*DB) WithNew

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

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

type Option

type Option func(*WrappedOptions)

func AllowRecovery

func AllowRecovery() Option

func SetPogrebOptions

func SetPogrebOptions(options pogreb.Options) Option

type Store

type Store struct {
	*pogreb.DB
	database.Searcher
	// contains filtered or unexported fields
}

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

func (*Store) Backend

func (pstore *Store) Backend() any

Backend returns the underlying pogreb instance.

func (*Store) Has

func (pstore *Store) Has(key []byte) bool

func (*Store) Keys

func (pstore *Store) Keys() [][]byte

func (*Store) Len

func (pstore *Store) Len() int

func (*Store) PrefixScan

func (pstore *Store) PrefixScan(prefixs 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) error channel will block, so be sure to read from it.

func (*Store) Search

func (pstore *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 (pstore *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.

type WrappedOptions

type WrappedOptions struct {
	*pogreb.Options
	// AllowRecovery allows the database to be recovered if a lockfile is detected upon running Init.
	AllowRecovery bool
}

Jump to

Keyboard shortcuts

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