Versions in this module Expand all Collapse all v2 v2.6.2 Aug 12, 2022 Changes in this version + const DefaultPurgeInterval + const GroupcacheRingKey + var ErrGroupcacheMiss = errors.New("cache miss") + 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 StringToBytes(s string) []byte + type BackgroundConfig struct + WriteBackBuffer int + WriteBackGoroutines int + 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 + Distributed bool + Enabled bool + MaxSizeMB int64 + PurgeInterval time.Duration + TTL time.Duration + func (cfg *EmbeddedCacheConfig) IsEnabledWithDistributed() bool + func (cfg *EmbeddedCacheConfig) IsEnabledWithoutDistributed() bool + func (cfg *EmbeddedCacheConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type EmbeddedCacheSingletonConfig struct + HeartbeatInterval time.Duration + HeartbeatTimeout time.Duration + ListenPort int + MaxSizeMB int64 + Ring RingCfg + WriteByteTimeout time.Duration + func (cfg *EmbeddedCacheSingletonConfig) 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(ctx context.Context, key string) ([]byte, bool) + func (c *FifoCache) GetCacheType() stats.CacheType + 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) GetCacheType() stats.CacheType + func (c GenNumMiddleware) Stop() + func (c GenNumMiddleware) Store(ctx context.Context, keys []string, buf [][]byte) error + type GroupCache struct + func NewGroupCache(rm ringManager, config GroupCacheConfig, logger log.Logger, ...) (*GroupCache, error) + func (c *GroupCache) NewGroup(name string, cfg *GroupConfig, ct stats.CacheType) Cache + func (c *GroupCache) Stats() *groupcache.Stats + type GroupCacheConfig struct + Cache Cache + Enabled bool + HeartbeatInterval time.Duration + HeartbeatTimeout time.Duration + ListenPort int + MaxSizeMB int64 + Ring RingCfg + WriteByteTimeout time.Duration + type GroupConfig struct + MaxSizeMB int64 + type GroupcacheRingManager struct + func NewGroupcacheRingManager(cfg GroupCacheConfig, log log.Logger, registerer prometheus.Registerer) (*GroupcacheRingManager, error) + func (rm *GroupcacheRingManager) Addr() string + func (rm *GroupcacheRingManager) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc) + func (rm *GroupcacheRingManager) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, ...) (ring.InstanceState, ring.Tokens) + func (rm *GroupcacheRingManager) OnRingInstanceStopping(_ *ring.BasicLifecycler) + func (rm *GroupcacheRingManager) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens) + func (rm *GroupcacheRingManager) Ring() ring.ReadRing + func (rm *GroupcacheRingManager) ServeHTTP(w http.ResponseWriter, req *http.Request) + 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) (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) 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 + Timeout time.Duration + func (cfg *RedisConfig) RegisterFlagsWithPrefix(prefix, description string, f *flag.FlagSet) + type RingCfg struct