Documentation
¶
Overview ¶
Cache package to provide an interface to interact with cache stores.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCacheIsDisabled = errors.New("cache is disabled") ErrRedisOptionsNil = errors.New("redis options is nil") )
Functions ¶
func GetCacheKey ¶
Helper that returns a cache key from the request URL and optional Authorization header.
`url` is the full request URL (including scheme, host, path, and query string). Any query parameters that affect the response should be left in the URL.
`authHeader` is the value of the HTTP `Authorization` header, if present.
Returns the full request url with a '-<hash>' appended at the end if an authHeader was provided.
Types ¶
type BigCacheStore ¶
type BigCacheStore struct {
// contains filtered or unexported fields
}
type Cache ¶
type Cache struct {
StoreType StoreType
TTL time.Duration
// contains filtered or unexported fields
}
func NewBigCache ¶
Creates a new Cache using BigCache.
Requires a BigCache config that can be created with bigcache.DefaultConfig(n*time.Minute).
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
type Store ¶
type Store interface {
// Returns an item from the cache. If no item is found, returns nil for the item and error.
Get(ctx context.Context, key string) ([]byte, error)
// Saves an item under the key provided.
Set(ctx context.Context, key string, value []byte) error
// Deletes an item from the cache.
Delete(ctx context.Context, key string) error
// Clears the entire cache.
//
// For Redis, the entire 'cache' namespace under 'equinox' is deleted.
Clear(ctx context.Context) error
}
Click to show internal directories.
Click to hide internal directories.