store

package
v0.9.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace = "RedQueen"
	DefaultNamespace = ""
)

Variables

View Source
var (
	ErrKeyAlreadyExists = errors.New("key already exists")
	ErrKeyNotFound      = errors.New("key not found")
)

Functions

func UnwrapGet

func UnwrapGet(val *Value, err error) ([]byte, error)

Types

type Actions

type Actions interface {
	Current() string
	Get(key []byte) (value *Value, err error)
	PrefixSearchScan(prefix []byte, reg string, offset, limit int) ([]*Value, error)
	PrefixScan(prefix []byte, offset, limit int) ([]*Value, error)
	SetWithTTL(key, value []byte, ttl uint32) error
	TrySetWithTTL(key, value []byte, ttl uint32) error
	Set(key, value []byte) error
	// TrySet try to set a key-value, returns an error if the key already exists
	TrySet(key, value []byte) error
	Del(key []byte) error
	Watch(key []byte) (notify Watcher, err error)
	WatchPrefix(prefix []byte) Watcher
}

type Store

type Store interface {
	Actions
	Swap(namespace string) (Actions, error)
	Close() error
	// Snapshot should be in tar & gzip format
	Snapshot() (io.Reader, error)
	Break(context.Context) error
	Restore(src io.Reader) (err error)
}

type Value

type Value struct {
	Timestamp uint64
	TTL       uint32
	Key       []byte
	Data      []byte
}

type WatchValue

type WatchValue struct {
	Seq       uint64
	Timestamp int64
	TTL       uint32
	Key       []byte
	// Value can be nil pointer, if Value is nil pointer then that the Value is deleted
	Value *[]byte
}

func (*WatchValue) Deleted

func (v *WatchValue) Deleted() bool

type Watcher

type Watcher interface {
	Notify() chan *WatchValue
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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