Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Get(key string) (entry *Entry, found bool) // Get a cache entry Set(key string, entry *Entry) error // Set a cache entry //Peek(key string) (entry *CacheEntry, found bool) // Peek for a cache entry, this should not trigger key-updates or weight/priorities to be changed Purge(key string) error PurgeTags(tags []string) error Flush() error }
Backend describes a cache backend, responsible for storing, flushing, setting and getting entries
func NewInMemoryCache ¶
func NewInMemoryCache() Backend
NewInMemoryCache creates a new lru TwoQueue backed cache backend
type Entry ¶
type Entry struct { Meta Meta Data interface{} }
Entry is a cached object with associated meta data
type FileBackend ¶
type FileBackend struct {
// contains filtered or unexported fields
}
FileBackend is a cache backend which saves the data in files
func NewFileBackend ¶
func NewFileBackend(baseDir string) *FileBackend
NewFileBackend returns a FileBackend operating in the given baseDir
func (*FileBackend) Flush ¶
func (*FileBackend) Flush() error
Flush is not supported by FileBackend and does nothing
func (*FileBackend) Get ¶
func (fb *FileBackend) Get(key string) (entry *Entry, found bool)
Get reads a cache entry
func (*FileBackend) Purge ¶
func (fb *FileBackend) Purge(key string) error
Purge deletes a cache entry
func (*FileBackend) PurgeTags ¶
func (*FileBackend) PurgeTags(tags []string) error
PurgeTags is not supported by FileBackend and does nothing
type HTTPFrontend ¶
type HTTPFrontend struct { singleflight.Group // contains filtered or unexported fields }
HTTPFrontend stores and caches http responses
func GetHTTPFrontendCacheWithNullBackend ¶
func GetHTTPFrontendCacheWithNullBackend() *HTTPFrontend
GetHTTPFrontendCacheWithNullBackend helper for tests
func (*HTTPFrontend) Get ¶
func (hf *HTTPFrontend) Get(ctx context.Context, key string, loader HTTPLoader) (*http.Response, error)
Get a http response, with tags and a loader the tags will be used when the entry is stored
func (*HTTPFrontend) Inject ¶
func (hf *HTTPFrontend) Inject(backend Backend, logger flamingo.Logger) *HTTPFrontend
Inject HTTPFrontend dependencies
type HTTPLoader ¶
HTTPLoader returns a response. it will be cached unless there is an error. this means 400/500 responses are cached too!
type Meta ¶
type Meta struct { Tags []string Lifetime, Gracetime time.Duration // contains filtered or unexported fields }
Meta describes life and gracetimes, as well as tags, for cache entries
type NullBackend ¶
type NullBackend struct{}
NullBackend does not store anything
func (*NullBackend) Get ¶
func (*NullBackend) Get(key string) (entry *Entry, found bool)
Get nothing
func (*NullBackend) PurgeTags ¶
func (*NullBackend) PurgeTags(tags []string) error
PurgeTags purges nothing
type StringFrontend ¶
type StringFrontend struct { singleflight.Group // contains filtered or unexported fields }
StringFrontend manages cache entries as strings
func (*StringFrontend) Get ¶
func (sf *StringFrontend) Get(key string, loader StringLoader) (string, error)
Get and load string cache entries
func (*StringFrontend) Inject ¶
func (sf *StringFrontend) Inject(backend Backend)
Inject StringFrontend dependencies
type StringLoader ¶
StringLoader is used to load strings for singleflight cache loads