storage

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: GPL-3.0, GPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExpireNever is the TTL value to use for an object that should never expire
	ExpireNever = time.Duration(-1)
)

Variables

View Source
var (
	// ErrorNotFound indicates that the requested data was not found
	ErrorNotFound = errors.New("data not found")
	// ErrorZeroLengthFileName indicates that the requested file name was zero length
	ErrorZeroLengthFileName = errors.New("zero length file name was provided")
	// ErrorZeroLengthData indicates that the data provided for storage was zero length
	ErrorZeroLengthData = errors.New("zero length data was provided")
)

Functions

This section is empty.

Types

type Mediator

type Mediator struct {
	StoreRetriever StoreRetriever
}

Mediator handles sanitising data before storage and (if necessary) after retrieval

func NewMediator

func NewMediator(sr StoreRetriever) Mediator

NewMediator instantiates a new Mediator for a gien StoreRetriever, allowing sanitisation of data before storage

func (*Mediator) Contains

func (sm *Mediator) Contains(fileName string) bool

Contains takes a path and returns whether or not the value is contained in the data store

func (*Mediator) Load

func (sm *Mediator) Load(fileName string) ([]byte, error)

Load implments the storage mediate interface to StoreRetriever and allows sanitising data loads

func (*Mediator) Store

func (sm *Mediator) Store(fileName string, data []byte) error

Store implements the storage mediator interface to StoreRetriever and allows sanitising data storage

type Retriever

type Retriever interface {
	Retrieve(key string) ([]byte, error)
	Contains(key string) bool
}

Retriever wraps the retriever function

type StoreRetriever

type StoreRetriever interface {
	Storer
	Retriever
}

StoreRetriever groups Storer and Retriever functions

type Storer

type Storer interface {
	Store(key string, data []byte) error
}

Storer wraps the store function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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