kv

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNop added in v0.57.0

func IsNop(kv KV) bool

IsNop tells whether kvs is nop KV.

Types

type Config added in v0.58.0

type Config struct {
	Type string        `fig:"type"`
	Etcd etcdkv.Config `fig:"etcd"`
}

Config defines cluster KV configuration.

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 kvtypes.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.

func New added in v0.58.0

func New(cfg Config, logger kitlog.Logger) (KV, error)

New returns a new initialized KV instance.

func NewNop added in v0.58.0

func NewNop() KV

NewNop returns a KV that doesn't do anything.

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 kvtypes.WatchResp

Watch watches on a key or prefix.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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