Documentation ¶
Overview ¶
Package cache provides application cache based on Redis. This feature can be turned off via configuration and in that case function Find return ErrNotFound and functions Set do nothing.
Index ¶
- Constants
- Variables
- func Find(ctx context.Context, key string, value Cacheable) error
- func Initialize()
- func Set(ctx context.Context, key string, value Cacheable) error
- func SetExpires(ctx context.Context, key string, value Cacheable, expiration time.Duration) error
- func SetForever(ctx context.Context, key string, value Cacheable) error
- type Cacheable
Constants ¶
const Forever = 24 * time.Hour * 30
Forever is used for items that should be cached "forever". Expiration of 30 days is used to allow cleanup of unused items.
Variables ¶
var ( ErrNotFound = errors.New("not found in cache") ErrNilValue = errors.New("value is nil") )
Functions ¶
func Find ¶
Find returns an item from cache. ErrNotFound is returned on cache miss or when the item cannot be deserialized
func Initialize ¶
func Initialize()
Initialize creates new Redis client if allowed by application config, or does nothing.
func Set ¶
Set creates or updates existing cache entry. It uses the default expiration duration specified in the application configuration. nolint: wrapcheck
func SetExpires ¶
SetExpires calls Set with specific expiration.