store

package
v0.0.0-...-9be3a58 Latest Latest
Warning

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

Go to latest
Published: May 22, 2017 License: BSD-3-Clause Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MEMCACHED string = "memcached"
	REDIS     string = "redis"
)

The backend store name

Variables

This section is empty.

Functions

func Register

func Register(name string, creator StoreCreator)

Register makes a store creator available by name.

Types

type Config

type Config struct {
	Timeout  time.Duration
	Addr     string // The address of the backend store with "host:port" format
	Password string // The authority password if necessarily
}

Config contains the options for a storage client

type GetResult

type GetResult struct {
	Err   error
	Value string
}

type Store

type Store interface {
	// Get gets a value by key
	// If the key is not found in the store, the Err is nil and Value is empty
	Get(key string) GetResult

	// MultiGet is a batch version of Get
	MultiGet(keys []string) map[string]GetResult

	// Set sets a value with key where the key exists or not
	Set(key, value string) error

	// Delete deletes a key/value pair from the store
	Delete(key string) error
}

func NewStore

func NewStore(name string, c Config) (db Store, err error)

NewStore creates a new store driver by store name and configurations.

type StoreCreator

type StoreCreator func(Config) (Store, error)

StoreCreator is a function to create a new instance of Store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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