store

package
v0.0.0-...-4db6957 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("not found")
View Source
var ErrNotSupported = errors.New("not supported")
View Source
var ErrUnknownOp = errors.New("unknown op")
View Source
var Tombstone = []byte{0x00}

Functions

This section is empty.

Types

type KVPair

type KVPair struct {
	Key   []byte
	Value []byte
}

type OpType

type OpType uint8
const (
	OpTypePut OpType = iota
	OpTypeDelete
)

type ScanStore

type ScanStore interface {
	Store
	Scan(ctx context.Context, start []byte, end []byte, limit int) ([]*KVPair, error)
}

func NewBoltStore

func NewBoltStore(path string) (ScanStore, error)

type ScanTTLStore

type ScanTTLStore interface {
	ScanStore
	TTLStore
}

type ScanTTLTxn

type ScanTTLTxn interface {
	ScanTxn
	TTLTxn
}

type ScanTxn

type ScanTxn interface {
	Txn
	Scan(ctx context.Context, start []byte, end []byte, limit int) ([]*KVPair, error)
}

type Store

type Store interface {
	Get(ctx context.Context, key []byte) ([]byte, error)
	Put(ctx context.Context, key []byte, value []byte) error
	Delete(ctx context.Context, key []byte) error
	Exists(ctx context.Context, key []byte) (bool, error)
	Snapshot() (io.ReadWriter, error)
	Restore(buf io.Reader) error
	Txn(ctx context.Context, f func(ctx context.Context, txn Txn) error) error
	Close() error
}

func NewMemoryStore

func NewMemoryStore() Store

type TTLStore

type TTLStore interface {
	Store
	Expire(ctx context.Context, key []byte, ttl int64) error
	PutWithTTL(ctx context.Context, key []byte, value []byte, ttl int64) error
	TxnWithTTL(ctx context.Context, f func(ctx context.Context, txn TTLTxn) error) error
}

func NewMemoryStoreDefaultTTL

func NewMemoryStoreDefaultTTL() TTLStore

func NewMemoryStoreWithExpire

func NewMemoryStoreWithExpire(interval time.Duration) TTLStore

type TTLTxn

type TTLTxn interface {
	Txn
	Expire(ctx context.Context, key []byte, ttl int64) error
	PutWithTTL(ctx context.Context, key []byte, value []byte, ttl int64) error
}

type Txn

type Txn interface {
	Get(ctx context.Context, key []byte) ([]byte, error)
	Put(ctx context.Context, key []byte, value []byte) error
	Delete(ctx context.Context, key []byte) error
	Exists(ctx context.Context, key []byte) (bool, error)
}

Jump to

Keyboard shortcuts

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