go-micro: github.com/micro/go-micro/store Index | Files | Directories

package store

import "github.com/micro/go-micro/store"

Package store is an interface for distribute data storage.


Package Files

options.go store.go

type Option Uses

type Option func(o *Options)

func Namespace Uses

func Namespace(ns string) Option

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

func Nodes Uses

func Nodes(a ...string) Option

Nodes is a list of nodes used to back the store

func Prefix Uses

func Prefix(p string) Option

Prefix sets a prefix to any key ids used

type Options Uses

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

type ReadOption Uses

type ReadOption func(o *ReadOptions)

func ReadPrefix Uses

func ReadPrefix() ReadOption

ReadPrefix uses the key as a prefix

func ReadSuffix Uses

func ReadSuffix() ReadOption

ReadSuffix uses the key as a suffix

type ReadOptions Uses

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

type Record Uses

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

Record represents a data record

type Store Uses

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)


cloudflarePackage cloudflare is a store implementation backed by cloudflare workers kv Note that the cloudflare workers KV API is eventually consistent.
cockroachPackage cockroach implements the cockroach store
etcdPackage etcd is an etcd v3 implementation of kv
memoryPackage memory is a in-memory store store
servicePackage service implements the store service interface

Package store imports 3 packages (graph) and is imported by 60 packages. Updated 2020-02-04. Refresh now. Tools for package owners.