store

package
v0.0.0-...-2b1e0a6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store is an interface for distribute data storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *Options)

func Namespace added in v1.15.0

func Namespace(ns string) Option

Namespace offers a way to have multiple isolated stores in the same backend, if supported.

func Nodes

func Nodes(a ...string) Option

Nodes is a list of nodes used to back the store

func Prefix

func Prefix(p string) Option

Prefix sets a prefix to any key ids used

type Options

type Options struct {
	// nodes to connect to
	Nodes []string
	// Namespace of the store
	Namespace string
	// Prefix of the keys used
	Prefix string
	// Alternative options
	Context context.Context
}

type ReadOption

type ReadOption func(o *ReadOptions)

func ReadPrefix

func ReadPrefix() ReadOption

ReadPrefix uses the key as a prefix

type ReadOptions

type ReadOptions struct {
	// Read key as a prefix
	Prefix bool
}

type Record

type Record struct {
	Key    string
	Value  []byte
	Expiry time.Duration
}

Record represents a data record

type Store

type Store interface {
	// Initialise store options
	Init(...Option) error
	// List all the known records
	List() ([]*Record, error)
	// Read records with keys
	Read(key string, opts ...ReadOption) ([]*Record, error)
	// Write records
	Write(*Record) error
	// Delete records with keys
	Delete(key string) error
	// Name of the store
	String() string
}

Store is a data storage interface

var (
	// ErrNotFound is returned when a Read key doesn't exist
	ErrNotFound = errors.New("not found")
	// Default store
	DefaultStore Store = new(noop)
)

Directories

Path Synopsis
Package cloudflare is a store implementation backed by cloudflare workers kv Note that the cloudflare workers KV API is eventually consistent.
Package cloudflare is a store implementation backed by cloudflare workers kv Note that the cloudflare workers KV API is eventually consistent.
Package cockroach implements the cockroach store
Package cockroach implements the cockroach store
Package etcd is an etcd v3 implementation of kv
Package etcd is an etcd v3 implementation of kv
Package memory is a in-memory store store
Package memory is a in-memory store store
Package service implements the store service interface
Package service implements the store service interface

Jump to

Keyboard shortcuts

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