Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// GetValue retrieves a value associated with a key from
// the backend store. If the key does not exist, an empty
// string should be returned.
GetValue(key string) (string, error)
// SetValue associates a key with a value in the backend
// store. Any additional tags supplied should be attached
// to the key. If the key already exists, the value should
// be updated. Concrete implementations of this interface
// are not required to clear old tags from the key (thus,
// clients should keep tags associated with a key stable).
SetValue(key, value string, tags ...string) error
// Remove removes a value from the backend store.
Remove(key string) error
// BustTags removes all keys associated with the given tags
// from the backend store.
BustTags(tags ...string) error
}
Cache is an interface to a backend key/value map with additional bookkeeping for attaching tas to certain keys.
func NewMemoryCache ¶
func NewMemoryCache(configs ...MemoryConfig) Cache
NewMemoryCache creates a Cache instance using a local memory backend.
func NewRedisCache ¶
func NewRedisCache(client deepjoy.Client, configs ...RedisConfig) Cache
NewRedisCache creates a Cache instance using a local memory backend.
type MemoryConfig ¶
type MemoryConfig func(*memoryCache)
MemoryConfig is a function use dot configure instances of a Cache which uses a memory backend.
func WithMemoryCapacity ¶
func WithMemoryCapacity(capacity int) MemoryConfig
WithMemoryCapacity sets the maximum number of items which are able to be stored in the memory backend.
type RedisConfig ¶
type RedisConfig func(*redisCache)
RedisConfig is a function use dot configure instances of a Cache which uses a Redis backend.
func WithRedisPrefix ¶
func WithRedisPrefix(prefix string) RedisConfig
WithRedisPrefix sets the prefix used in the Redis backend.
func WithRedisTTL ¶
func WithRedisTTL(ttl time.Duration) RedisConfig
WithRedisTTL sets the TTL for keys stored in the Redis backend.
