keyvalue

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxRetires   = 3
	DialTimeout  = 10 * time.Second
	ReadTimeout  = 10 * time.Second
	WriteTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MemStore

type MemStore map[string]string

MemStore implements Client interface. It stores cache key-value mappings in memory.

func (MemStore) Cleanup

func (m MemStore) Cleanup() error

Cleanup does nothing, but is implemented to comply with Client interface.

func (MemStore) Get

func (m MemStore) Get(key string) (string, error)

Get returns the value of a key previously set in memory.

func (MemStore) Put

func (m MemStore) Put(key, value string) error

Put stores a key and its value in memory.

type Store

type Store interface {
	Get(string) (string, error)
	Put(string, string) error
	Cleanup() error
}

Store is the interface that the CacheManager relies on to find the mapping between cacheID and layer name. The Get function returns an empty string and no error if the key was not found in the store. Cleanup closes potential connections to the store.

func NewFSStore

func NewFSStore(fullpath string, sandboxDir string, ttl time.Duration) (Store, error)

NewFSStore returns a Store backed by the local filesystem. Entries are stored in json format. TODO: enforce capacity.

func NewHTTPStore

func NewHTTPStore(address string, headers ...string) (Store, error)

NewHTTPStore returns a new instance of Store backed by a server that implements the following API: GET <address>/key => http.StatusOK with value in body PUT <address>/key => 200 <= code < 300 The "headers" entries are of the form <header>:<value>.

func NewRedisStore

func NewRedisStore(addr string, ttl time.Duration) (Store, error)

NewRedisStore returns a new instance of Store backed by a redis server. In this constructor we try to open a connection to redis. If that attempt fails we return an error. If it succeeds we just close that connection.

Jump to

Keyboard shortcuts

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