cache

package
v0.0.0-...-b371572 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchKey is returned when a key is not found
	ErrNoSuchKey = errors.New("no such key")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(string) ([]byte, error)
	Set(string, []byte) error
	Keys() ([]string, error)
	Delete(string) error
}

Cache is the interface that

func NewFSCache

func NewFSCache(root string) (Cache, error)

NewFSCache returns a FileSystemcache with defaults set, and makes sure that the FSCache has a directory to store info in.

type FSCache

type FSCache struct {
	Root string
}

FSCache is an implementation of Cache that stores information in the filesystem

func (*FSCache) Delete

func (fs *FSCache) Delete(key string) error

Delete removes a key or returns ErrNoSuchKey

func (*FSCache) Get

func (fs *FSCache) Get(key string) ([]byte, error)

Get returns the content under key or ErrNoSuchKey

func (*FSCache) Keys

func (fs *FSCache) Keys() ([]string, error)

Keys returns the keys managed by this cache

func (*FSCache) Set

func (fs *FSCache) Set(key string, content []byte) error

Set writes the content under the given key

func (*FSCache) Setup

func (fs *FSCache) Setup() error

Setup creates the directory for storage, if it doesn't exist

Jump to

Keyboard shortcuts

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