cache

package
v0.0.0-...-84c28d5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetValue

func SetValue(value interface{}, result interface{})

SetValue will write result to value

Types

type Cache

type Cache interface {
	GetAndLoad(key string, value interface{}, loader func() (interface{}, error)) error
	Get(key string, value interface{}) error
	// right now uses caches default expire. Might want to add one with override in future
	Set(key string, value interface{}) error
}

Cache can GetAndLoad items

func New

func New(backend Storage, expiration time.Duration, ignoreSetErrors bool, log Logger) Cache

New returns a new *Cache

func NewMock

func NewMock() Cache

NewMock returns a Cache that doesn't actually cache anything

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger can log using Printf

type Storage

type Storage interface {
	Get(key string, value interface{}) error
	Set(key string, value interface{}, expiration time.Duration) error
}

Storage provides Get and Set to a cache backend

Jump to

Keyboard shortcuts

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