Documentation ¶
Overview ¶
Package cache defines a common interface for cache implementations that can be used by PiService implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Return the string that was set for key (or "" if unset) and an Error // if the implementation failed. // NOTE: a cache miss *should not* return an error. GetValue(ctx context.Context, key string) (string, error) // Store the value string with the provided key, returning an error if // the implementation failed. SetValue(ctx context.Context, key string, value string) error }
Cache defines an interface for a cache implementation that can be used to store the results of a calculation for subsequent lookup requests.
type NoopCache ¶
type NoopCache struct{}
NoopCache implements Cache interface without any real caching.
func NewNoopCache ¶
func NewNoopCache() *NoopCache
Creates a no-operation Cache implementation that satisfies the interface requirements without performing any real caching. All values are silently dropped by SetValue and calls to GetValue always return an empty string.
type RedisCache ¶
RedisCache implements Cache interface backed by a Redis store.
func NewRedisCache ¶
func NewRedisCache(ctx context.Context, endpoint string, options ...RedisCacheOption) *RedisCache
Return a new Cache implementation using Redis as a backend.
type RedisCacheOption ¶
type RedisCacheOption func(*RedisCache)