Versions in this module Expand all Collapse all v2 v2.0.0 Jun 14, 2023 Changes in this version + const DefaultPurgeInterval + 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 IsFifoCacheSet(cfg Config) 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 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 + EmbeddedCache EmbeddedCacheConfig + 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 EmbeddedCacheConfig struct + Enabled bool + MaxSizeMB int64 + PurgeInterval time.Duration + TTL time.Duration + func (cfg *EmbeddedCacheConfig) IsEnabled() bool + func (cfg *EmbeddedCacheConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + 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(_ context.Context, key string) ([]byte, bool) + func (c *FifoCache) GetCacheType() stats.CacheType + func (c *FifoCache) Stop() + func (c *FifoCache) Store(_ 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) 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 + 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 DefaultMemcachedJumpHashSelector() *MemcachedJumpHashSelector + func NewMemcachedJumpHashSelector(resolveUnixAddr UnixResolver, resolveTCPAddr TCPResolver) *MemcachedJumpHashSelector + 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) 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 TCPResolver func(network, address string) (*net.TCPAddr, error) + type UnixResolver func(network, address string) (*net.UnixAddr, error)