cache

package
v0.0.0-...-ff244ab Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a rudimentary key/value caching store backed by redis. It offers a Get/Set interface as well a its gzip compressed alternative GetCompressed/SetCompressed

func New

func New(client redis.UniversalClient) Cache

New returns a new Cache from a potentially nil redis client.

func (Cache) Clear

func (c Cache) Clear(key string)

Clear removes a key from the cache

func (Cache) Get

func (c Cache) Get(key string) (io.Reader, bool)

Get fetch the cached asset at the given key, and returns true only if the asset was found.

func (Cache) GetCompressed

func (c Cache) GetCompressed(key string) (io.Reader, bool)

GetCompressed works like Get but expect a compressed asset that is uncompressed.

func (Cache) RefreshTTL

func (c Cache) RefreshTTL(key string, expiration time.Duration)

RefreshTTL can be used to update the TTL of an existing entry in the cache.

func (Cache) Set

func (c Cache) Set(key string, data []byte, expiration time.Duration)

Set stores an asset to the given key.

func (Cache) SetCompressed

func (c Cache) SetCompressed(key string, data []byte, expiration time.Duration)

SetCompressed works like Set but compress the asset data before storing it.

Jump to

Keyboard shortcuts

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