store

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyExists means the given key already exists in the store.
	ErrKeyExists = verror.NewID("KeyExists")
	// ErrUnknownKey means the given key does not exist in the store.
	ErrUnknownKey = verror.NewID("UnknownKey")
)

Functions

This section is empty.

Types

type Store

type Store interface {
	// Get returns the value for the given key (decoding into v).
	// Fails if the given key is unknown (ErrUnknownKey).
	Get(k string, v interface{}) (version string, err error)

	// Insert writes the given value for the given key.
	// Fails if an entry already exists for the given key (ErrKeyExists).
	Insert(k string, v interface{}) error

	// Update writes the given value for the given key.
	// Fails if the given key is unknown (ErrUnknownKey).
	// Fails if version doesn't match (ErrBadVersion).
	Update(k string, v interface{}, version string) error

	// Delete deletes the entry for the given key.
	// Fails if the given key is unknown (ErrUnknownKey).
	// Fails if version doesn't match (ErrBadVersion).
	Delete(k string, version string) error

	// Close closes the store. All subsequent method calls will fail.
	Close() error
}

Store is a key-value store that uses versions for optimistic concurrency control. The versions passed to Update and Delete must come from Get. If in the meantime some client has called Update or Delete on the same key, the version will be stale and the method call will fail.

Note, this API disallows empty versions to simplify implementation. The group server is the only client of this API and always specifies versions.

Directories

Path Synopsis
Package mem provides a simple, in-memory implementation of server.Store.
Package mem provides a simple, in-memory implementation of server.Store.

Jump to

Keyboard shortcuts

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