storage

package
v0.1.1-0...-0c1194d Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeBadger = "badger"
	TypeMemory = "memory"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerStorage

type BadgerStorage struct {
	Storage
	// contains filtered or unexported fields
}

func (*BadgerStorage) Close

func (storage *BadgerStorage) Close() error

func (*BadgerStorage) Del

func (storage *BadgerStorage) Del(keys [][]byte) error

func (*BadgerStorage) Get

func (storage *BadgerStorage) Get(key []byte) ([]byte, error)

func (*BadgerStorage) LoadSnapshot

func (storage *BadgerStorage) LoadSnapshot(ctx context.Context, reader io.Reader) error

func (*BadgerStorage) Scan

func (storage *BadgerStorage) Scan(scanOpts ScanOptions) ([]KVPair, error)

func (*BadgerStorage) Set

func (storage *BadgerStorage) Set(key, val []byte, ttl uint64) error

func (*BadgerStorage) Snapshot

func (storage *BadgerStorage) Snapshot(ctx context.Context, writer io.Writer) error

func (*BadgerStorage) TTL

func (storage *BadgerStorage) TTL(key []byte) (uint64, error)

type KVPair

type KVPair struct {
	Key, Val []byte
}

func (*KVPair) SetKey

func (p *KVPair) SetKey(key []byte)

func (*KVPair) SetVal

func (p *KVPair) SetVal(val []byte)

type MemoryStorage

type MemoryStorage struct {
	Storage
	// contains filtered or unexported fields
}

func (*MemoryStorage) Close

func (storage *MemoryStorage) Close() error

func (*MemoryStorage) Del

func (storage *MemoryStorage) Del(keys [][]byte) error

func (*MemoryStorage) Get

func (storage *MemoryStorage) Get(key []byte) ([]byte, error)

func (*MemoryStorage) Scan

func (storage *MemoryStorage) Scan(scanOpts ScanOptions) ([]KVPair, error)

func (*MemoryStorage) Set

func (storage *MemoryStorage) Set(key, val []byte, ttl uint64) error

func (*MemoryStorage) TTL

func (storage *MemoryStorage) TTL(key []byte) (uint64, error)

type Options

type Options struct {
	Storage string
	Dir     string
}

type ScanOptions

type ScanOptions struct {
	Pattern      string
	Limit        int
	IncludeValue bool
}

type Storage

type Storage interface {
	Get(key []byte) ([]byte, error)
	Set(key, val []byte, ttl uint64) error
	Del(keys [][]byte) error
	TTL(key []byte) (uint64, error)
	Scan(scanOpts ScanOptions) ([]KVPair, error)
	Close() error

	Snapshot(ctx context.Context, writer io.Writer) error
	LoadSnapshot(ctx context.Context, reader io.Reader) error
}

func NewBadgerStorage

func NewBadgerStorage(options Options) (Storage, error)

func NewMemoryStorage

func NewMemoryStorage(options Options) (Storage, error)

func NewStorage

func NewStorage(options Options) (Storage, error)

Jump to

Keyboard shortcuts

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