Documentation ¶
Index ¶
- type Cache
- func (c Cache) CheckStatus() (time.Duration, error)
- func (c Cache) Clear(key string)
- func (c Cache) Get(key string) ([]byte, bool)
- func (c Cache) GetCompressed(key string) (io.Reader, bool)
- func (c Cache) Keys(prefix string) []string
- func (c Cache) MultiGet(keys []string) [][]byte
- func (c Cache) RefreshTTL(key string, expiration time.Duration)
- func (c Cache) Set(key string, data []byte, expiration time.Duration)
- func (c Cache) SetCompressed(key string, data []byte, expiration time.Duration)
- func (c Cache) SetNX(key string, data []byte, expiration time.Duration)
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) CheckStatus ¶
CheckStatus checks that the cache is ready, or returns an error.
func (Cache) Get ¶
Get fetch the cached asset at the given key, and returns true only if the asset was found.
func (Cache) GetCompressed ¶
GetCompressed works like Get but expect a compressed asset that is uncompressed.
func (Cache) Keys ¶
Keys returns the list of keys with the given prefix. Note: it can be slow and should be used carefully.
func (Cache) RefreshTTL ¶
RefreshTTL can be used to update the TTL of an existing entry in the cache.
func (Cache) SetCompressed ¶
SetCompressed works like Set but compress the asset data before storing it.