gache: github.com/efritz/gache Index | Files | Directories

package gache

import "github.com/efritz/gache"

Index

Package Files

cache.go memory.go memory_options.go redis.go redis_options.go redis_scripts.go

type Cache Uses

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 Uses

func NewMemoryCache(configs ...MemoryConfig) Cache

NewMemoryCache creates a Cache instance using a local memory backend.

func NewRedisCache Uses

func NewRedisCache(client deepjoy.Client, configs ...RedisConfig) Cache

NewRedisCache creates a Cache instance using a local memory backend.

type MemoryConfig Uses

type MemoryConfig func(*memoryCache)

MemoryConfig is a function use dot configure instances of a Cache which uses a memory backend.

func WithMemoryCapacity Uses

func WithMemoryCapacity(capacity int) MemoryConfig

WithMemoryCapacity sets the maximum number of items which are able to be stored in the memory backend.

type RedisConfig Uses

type RedisConfig func(*redisCache)

RedisConfig is a function use dot configure instances of a Cache which uses a Redis backend.

func WithRedisPrefix Uses

func WithRedisPrefix(prefix string) RedisConfig

WithRedisPrefix sets the prefix used in the Redis backend.

func WithRedisTTL Uses

func WithRedisTTL(ttl time.Duration) RedisConfig

WithRedisTTL sets the TTL for keys stored in the Redis backend.

Directories

PathSynopsis
mock

Package gache imports 6 packages (graph). Updated 2019-01-22. Refresh now. Tools for package owners.