Versions in this module Expand all Collapse all v3 v3.0.0 Apr 8, 2024 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 IsCacheConfigured(cfg Config) bool + func IsEmbeddedCacheSet(cfg Config) bool + func IsEmptyTieredCache(cache Cache) bool + func IsMemcacheSet(cfg Config) bool + func IsRedisSet(cfg Config) bool + func IsSpecificImplementationSet(cfg Config) bool + func StringToBytes(s string) []byte + type BackgroundConfig struct + WriteBackBuffer int + WriteBackGoroutines int + WriteBackSizeLimit flagext.ByteSize + func (cfg *BackgroundConfig) RegisterFlagsWithPrefix(prefix string, description string, f *flag.FlagSet) + type Cache interface + Fetch func(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) + GetCacheType func() stats.CacheType + Stop func() + Store func(ctx context.Context, key []string, buf [][]byte) error + func CollectStats(cache Cache) Cache + 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 NewNoopCache() Cache + func NewSnappy(next Cache, logger log.Logger) Cache + func NewTiered(caches []Cache) Cache + func StopOnce(cache Cache) Cache + type Config struct + Background BackgroundConfig + Cache Cache + DefaultValidity time.Duration + EmbeddedCache EmbeddedCacheConfig + Memcache MemcachedConfig + MemcacheClient MemcachedClientConfig + Prefix string + Redis RedisConfig + func (cfg *Config) RegisterFlagsWithPrefix(prefix string, description string, f *flag.FlagSet) + type EmbeddedCache struct + func NewEmbeddedCache(name string, cfg EmbeddedCacheConfig, reg prometheus.Registerer, ...) *EmbeddedCache[string, []byte] + func NewTypedEmbeddedCache[K comparable, V any](name string, cfg EmbeddedCacheConfig, reg prometheus.Registerer, ...) *EmbeddedCache[K, V] + func (c *EmbeddedCache[K, V]) Fetch(ctx context.Context, keys []K) (foundKeys []K, foundValues []V, missingKeys []K, err error) + func (c *EmbeddedCache[K, V]) Get(_ context.Context, key K) (V, bool) + func (c *EmbeddedCache[K, V]) GetCacheType() stats.CacheType + func (c *EmbeddedCache[K, V]) Stop() + func (c *EmbeddedCache[K, V]) Store(_ context.Context, keys []K, values []V) error + type EmbeddedCacheConfig struct + Enabled bool + MaxSizeItems int + MaxSizeMB int64 + PurgeInterval time.Duration + TTL time.Duration + func (cfg *EmbeddedCacheConfig) IsEnabled() bool + func (cfg *EmbeddedCacheConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + func (cfg *EmbeddedCacheConfig) RegisterFlagsWithPrefixAndDefaults(prefix, description string, f *flag.FlagSet, defaultTTL time.Duration) + type Entry struct + Key K + Value V + type GenNumMiddleware struct + func (c GenNumMiddleware) Fetch(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error) + func (c GenNumMiddleware) GetCacheType() stats.CacheType + 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) GetCacheType() stats.CacheType + func (c *Memcached) Stop() + func (c *Memcached) Store(ctx context.Context, keys []string, bufs [][]byte) error + type MemcachedClient interface + GetMulti func(keys []string, opts ...memcache.Option) (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 + TLS dstls.ClientConfig + TLSEnabled bool + 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 MockCache interface + GetInternal func() map[string][]byte + GetKeys func() []string + KeysRequested func() int + NumKeyUpdates func() int + func NewMockCache() MockCache + 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) GetCacheType() stats.CacheType + 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 + RouteRandomly bool + Timeout time.Duration + Username string + func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type TypedCache interface + Fetch func(ctx context.Context, keys []K) (found []K, values []V, missing []K, err error) + GetCacheType func() stats.CacheType + Stop func() + Store func(ctx context.Context, keys []K, values []V) error + func NewNoopTypedCache[K comparable, V any]() TypedCache[K, V]