Versions in this module Expand all Collapse all v2 v2.4.3 Feb 9, 2022 Changes in this version + func ExtractCacheGenNumber(ctx context.Context) string + func HashKey(key string) string + func InjectCacheGenNumber(ctx context.Context, cacheGen string) context.Context + func IsEmptyTieredCache(cache Cache) bool + func IsMemcacheSet(cfg Config) bool + func IsRedisSet(cfg Config) bool + func StringToBytes(s string) []byte + type BackgroundConfig struct + WriteBackBuffer int + WriteBackGoroutines int + func (cfg *BackgroundConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type Cache interface + Fetch func(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) + Stop func() + Store func(ctx context.Context, key []string, buf [][]byte) error + func Instrument(name string, cache Cache, reg prometheus.Registerer) Cache + func New(cfg Config, reg prometheus.Registerer, logger log.Logger) (Cache, error) + func NewBackground(name string, cfg BackgroundConfig, cache Cache, reg prometheus.Registerer) Cache + func NewCacheGenNumMiddleware(downstreamCache Cache) Cache + func NewMockCache() Cache + func NewNoopCache() Cache + func NewSnappy(next Cache, logger log.Logger) Cache + func NewTiered(caches []Cache) Cache + func StopOnce(cache Cache) Cache + type Config struct + AsyncCacheWriteBackBufferSize int + AsyncCacheWriteBackConcurrency int + Background BackgroundConfig + Cache Cache + DefaultValidity time.Duration + EnableFifoCache bool + Fifocache FifoCacheConfig + Memcache MemcachedConfig + MemcacheClient MemcachedClientConfig + Prefix string + Redis RedisConfig + func (cfg *Config) RegisterFlagsWithPrefix(prefix string, description string, f *flag.FlagSet) + func (cfg *Config) Validate() error + type FifoCache struct + func NewFifoCache(name string, cfg FifoCacheConfig, reg prometheus.Registerer, logger log.Logger) *FifoCache + func (c *FifoCache) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) + func (c *FifoCache) Get(ctx context.Context, key string) ([]byte, bool) + func (c *FifoCache) Stop() + func (c *FifoCache) Store(ctx context.Context, keys []string, values [][]byte) error + type FifoCacheConfig struct + DeprecatedSize int + DeprecatedValidity time.Duration + MaxSizeBytes string + MaxSizeItems int + PurgeInterval time.Duration + TTL time.Duration + func (cfg *FifoCacheConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + func (cfg *FifoCacheConfig) Validate() error + type GenNumMiddleware struct + func (c GenNumMiddleware) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) + func (c GenNumMiddleware) Stop() + func (c GenNumMiddleware) Store(ctx context.Context, keys []string, buf [][]byte) error + type Memcached struct + func NewMemcached(cfg MemcachedConfig, client MemcachedClient, name string, ...) *Memcached + func (c *Memcached) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missed []string, err error) + func (c *Memcached) Stop() + func (c *Memcached) Store(ctx context.Context, keys []string, bufs [][]byte) error + type MemcachedClient interface + GetMulti func(keys []string) (map[string]*memcache.Item, error) + Set func(item *memcache.Item) error + func NewMemcachedClient(cfg MemcachedClientConfig, name string, r prometheus.Registerer, ...) MemcachedClient + type MemcachedClientConfig struct + Addresses string + CBFailures uint + CBInterval time.Duration + CBTimeout time.Duration + ConsistentHash bool + Host string + MaxIdleConns int + MaxItemSize int + Service string + Timeout time.Duration + UpdateInterval time.Duration + func (cfg *MemcachedClientConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type MemcachedConfig struct + BatchSize int + Expiration time.Duration + Parallelism int + func (cfg *MemcachedConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type MemcachedJumpHashSelector struct + func (s *MemcachedJumpHashSelector) Each(f func(net.Addr) error) error + func (s *MemcachedJumpHashSelector) PickServer(key string) (net.Addr, error) + func (s *MemcachedJumpHashSelector) SetServers(servers ...string) error + type RedisCache struct + func NewRedisCache(name string, redisClient *RedisClient, logger log.Logger) *RedisCache + func (c *RedisCache) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missed []string, err error) + func (c *RedisCache) Stop() + func (c *RedisCache) Store(ctx context.Context, keys []string, bufs [][]byte) error + type RedisClient struct + func NewRedisClient(cfg *RedisConfig) (*RedisClient, error) + func (c *RedisClient) Close() error + func (c *RedisClient) MGet(ctx context.Context, keys []string) ([][]byte, error) + func (c *RedisClient) MSet(ctx context.Context, keys []string, values [][]byte) error + func (c *RedisClient) Ping(ctx context.Context) error + type RedisConfig struct + DB int + EnableTLS bool + Endpoint string + Expiration time.Duration + IdleTimeout time.Duration + InsecureSkipVerify bool + MasterName string + MaxConnAge time.Duration + Password flagext.Secret + PoolSize int + Timeout time.Duration + func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet)