store

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStores

func GetStores(f Factory, names ...[]byte) (slice.Slice[Store], error)

func GetStoresStr

func GetStoresStr(f Factory, names ...string) (slice.Slice[Store], error)

func Slice

func Slice(s Store) slice.Slice[[]byte]

Types

type Factory

type Factory interface {
	// Store acts as an Upsert operation, it will get the Store if it exists
	// and create it if it does not.
	Store(name []byte) (Store, error)
}

Factory for creating a Store

type Iter

type Iter struct {
	Store
	Key []byte
	filter.Filter[[]byte]
	I int
}

func NewIter

func NewIter(s Store) *Iter

func (*Iter) Cur

func (i *Iter) Cur() (key []byte, done bool)

func (*Iter) CurVal

func (i *Iter) CurVal() (key []byte, r Record, done bool)

func (*Iter) Done

func (i *Iter) Done() bool

func (*Iter) Idx

func (i *Iter) Idx() int

func (*Iter) Next

func (i *Iter) Next() (key []byte, done bool)

type Record

type Record struct {
	Found bool
	Value []byte
	Store Store
}

Record is returned from a call to Store.Get. Found indicates if the key was found. If it was either the Value or the Store will not be nil.

type Store

type Store interface {
	// Put a key,value pair. This will over write an existing value. An error
	// is returned if there is a collision with a Sub-Store.
	Put(key, value []byte) error
	// Get returns the value stored at the key. The Record will contain either
	// a Value or a Store if the key exists.
	Get(key []byte) Record
	// Next returns the next key greater than the one provided. If nil is passed
	// in, the lowest key is returned. If the highest key in the store is passed
	// in, nil is returned.
	Next(key []byte) (nextKey []byte)
	// Delete will delete either a key or a Sub-Store
	Delete(key []byte) error

	// Store fulfills Factory allowing Sub-Stores to be created.
	Factory
}

Store of key/value pairs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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