keyvalue

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 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 MockStore added in v0.1.12

type MockStore map[string]string

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

func (MockStore) Cleanup added in v0.1.12

func (m MockStore) Cleanup() error

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

func (MockStore) Get added in v0.1.12

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

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

func (MockStore) Put added in v0.1.12

func (m MockStore) 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, password 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