store

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound = errors.New("KeyNotFound")
)

Functions

This section is empty.

Types

type DelOpts

type DelOpts struct {
	K   []byte
	Fns []SelectFn
}

type KV

type KV struct {
	K, V []byte
}

type SelectFn

type SelectFn func(k []byte) bool

func WithPrefix

func WithPrefix(prefix []byte) SelectFn

type Store

type Store interface {
	CreateCache(ctx context.Context, name string) error
	ListCaches(ctx context.Context) ([]string, error)
	DeleteCache(ctx context.Context, name string) error

	SetPruneIndex(ctx context.Context, name string, idx uint8) error
	GetPruneIndex(ctx context.Context, name string) (uint8, error)
	Prune(ctx context.Context, name, bucket string, pruneIndex uint8) error

	Clone(ctx context.Context, name, cname string) error

	WriteValue(ctx context.Context, name, bucket string, k []byte, v []byte, m byte) error
	DeleteValue(ctx context.Context, name, bucket string, k []byte) error
	DeletePrefix(ctx context.Context, name, bucket string, k []byte, fn ...SelectFn) error
	Txn(ctx context.Context, name, bucket string, txnOpts *TxnOpts) error

	GetValue(ctx context.Context, name, bucket string, k []byte) ([]byte, error)
	GetAll(ctx context.Context, name, bucket string, keysOnly bool, fn ...SelectFn) (chan *KV, error)
	GetPrefix(ctx context.Context, name, bucket string, prefix, pattern []byte, fn ...SelectFn) (chan *KV, error)
	//
	GetBatch(ctx context.Context, name, bucket string, keys [][]byte, fn ...SelectFn) (chan *KV, error)
	//
	GetN(ctx context.Context, name, bucket string, n uint64, fn ...SelectFn) ([]*KV, error)
	Watch(ctx context.Context, name, bucket string, prefixes [][]byte) (chan *KV, error)

	Close() error
	Clear(ctx context.Context, name string) error
}

func New

func New(typ, p string) (Store, error)

type StoreStats

type StoreStats struct {
	NumCache      int
	KeysPerBucket map[string]int64
}

type TxnOpts

type TxnOpts struct {
	Updates []*KV
	Deletes []*DelOpts
}

Jump to

Keyboard shortcuts

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