kv

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV interface {
	// Put stores a new value associated to a given key.
	Put(ctx context.Context, key string, value string) error

	// Get retrieves a value associated to a given key.
	Get(ctx context.Context, key string) ([]byte, error)

	// GetPrefix retrieves all values whose key matches prefix.
	GetPrefix(ctx context.Context, prefix string) (map[string][]byte, error)

	// Del deletes a value associated to a given key.
	Del(ctx context.Context, key string) error

	// Watch watches on a key or prefix.
	Watch(ctx context.Context, prefix string, withPrevVal bool) <-chan WatchResp

	// Start initializes key-value store.
	Start(ctx context.Context) error

	// Stop releases all underlying key-value store resources.
	Stop(ctx context.Context) error
}

KV represents a generic key-value store interface.

type Measured

type Measured struct {
	// contains filtered or unexported fields
}

Measured represents a measured KV type.

func NewMeasured

func NewMeasured(kv KV) *Measured

NewMeasured returns an initialized measured KV instance.

func (*Measured) Del

func (m *Measured) Del(ctx context.Context, key string) error

Del deletes a value associated to a given key.

func (*Measured) Get

func (m *Measured) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value associated to a given key.

func (*Measured) GetPrefix

func (m *Measured) GetPrefix(ctx context.Context, prefix string) (map[string][]byte, error)

GetPrefix retrieves all values whose key matches prefix.

func (*Measured) Put

func (m *Measured) Put(ctx context.Context, key string, value string) error

Put stores a new value associated to a given key.

func (*Measured) Start

func (m *Measured) Start(ctx context.Context) error

Start initializes key-value store.

func (*Measured) Stop

func (m *Measured) Stop(ctx context.Context) error

Stop releases all underlying key-value store resources.

func (*Measured) Watch

func (m *Measured) Watch(ctx context.Context, prefix string, withPrevVal bool) <-chan WatchResp

Watch watches on a key or prefix.

type WatchEvent

type WatchEvent struct {
	Type    WatchEventType
	Key     string
	Val     []byte
	PrevVal []byte
}

WatchEvent represents a single watched event.

type WatchEventType

type WatchEventType uint8

WatchEventType represents a key watch event type.

const (
	// Put represents a put key-value event type.
	Put WatchEventType = iota

	// Del represents a delete key-value event type.
	Del
)

type WatchResp

type WatchResp struct {
	Events []WatchEvent
	Err    error
}

WatchResp contains a watch operation response value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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