Documentation ¶
Index ¶
- Variables
- func RegisterCacheStatsCollector(galaxy *galaxycache.Galaxy, reg prometheus.Registerer)
- type AttributesConfig
- type Cache
- type CacheStatsCollector
- type CachingBucketConfig
- func (cfg *CachingBucketConfig) AllConfigNames() map[string][]string
- func (cfg *CachingBucketConfig) CacheAttributes(configName string, cache Cache, matcher func(name string) bool, ...)
- func (cfg *CachingBucketConfig) CacheExists(configName string, cache Cache, matcher func(string) bool, ...)
- func (cfg *CachingBucketConfig) CacheGet(configName string, cache Cache, matcher func(string) bool, ...)
- func (cfg *CachingBucketConfig) CacheGetRange(configName string, cache Cache, matcher func(string) bool, subrangeSize int64, ...)
- func (cfg *CachingBucketConfig) CacheIter(configName string, cache Cache, matcher func(string) bool, ttl time.Duration, ...)
- func (cfg *CachingBucketConfig) FindAttributesConfig(name string) (string, *AttributesConfig)
- func (cfg *CachingBucketConfig) FindExistConfig(name string) (string, *ExistsConfig)
- func (cfg *CachingBucketConfig) FindGetConfig(name string) (string, *GetConfig)
- func (cfg *CachingBucketConfig) FindGetRangeConfig(name string) (string, *GetRangeConfig)
- func (cfg *CachingBucketConfig) FindIterConfig(dir string) (string, *IterConfig)
- func (cfg *CachingBucketConfig) SetCacheImplementation(c Cache)
- type ExistsConfig
- type GetConfig
- type GetRangeConfig
- type Groupcache
- type GroupcacheConfig
- type InMemoryCache
- type InMemoryCacheConfig
- type IterCodec
- type IterConfig
- type MemcachedCache
- type OperationConfig
- type RedisCache
- type TracingCache
Constants ¶
This section is empty.
Variables ¶
var ( DefaultGroupcacheConfig = GroupcacheConfig{ MaxSize: 250 * 1024 * 1024, DNSSDResolver: dns.GolangResolverType, DNSInterval: 1 * time.Minute, Timeout: 2 * time.Second, } )
var (
DefaultInMemoryCacheConfig = InMemoryCacheConfig{
MaxSize: 250 * 1024 * 1024,
MaxItemSize: 125 * 1024 * 1024,
}
)
Functions ¶
func RegisterCacheStatsCollector ¶
func RegisterCacheStatsCollector(galaxy *galaxycache.Galaxy, reg prometheus.Registerer)
RegisterCacheStatsCollector registers a groupcache metrics collector.
Types ¶
type AttributesConfig ¶
type AttributesConfig struct { OperationConfig TTL time.Duration }
type Cache ¶
type Cache interface { // Store data into the cache. // // Note that individual byte buffers may be retained by the cache! Store(ctx context.Context, data map[string][]byte, ttl time.Duration) // Fetch multiple keys from cache. Returns map of input keys to data. // If key isn't in the map, data for given key was not found. Fetch(ctx context.Context, keys []string) map[string][]byte Name() string }
Generic best-effort cache.
func NewTracingCache ¶
type CacheStatsCollector ¶
type CacheStatsCollector struct {
// contains filtered or unexported fields
}
func (*CacheStatsCollector) Collect ¶
func (s *CacheStatsCollector) Collect(ch chan<- prometheus.Metric)
func (*CacheStatsCollector) Describe ¶
func (s *CacheStatsCollector) Describe(ch chan<- *prometheus.Desc)
type CachingBucketConfig ¶
type CachingBucketConfig struct {
// contains filtered or unexported fields
}
CachingBucketConfig contains low-level configuration for individual bucket operations. This is not exposed to the user, but it is expected that code sets up individual operations based on user-provided configuration.
func NewCachingBucketConfig ¶
func NewCachingBucketConfig() *CachingBucketConfig
func (*CachingBucketConfig) AllConfigNames ¶
func (cfg *CachingBucketConfig) AllConfigNames() map[string][]string
func (*CachingBucketConfig) CacheAttributes ¶
func (cfg *CachingBucketConfig) CacheAttributes(configName string, cache Cache, matcher func(name string) bool, ttl time.Duration)
CacheAttributes configures caching of "Attributes" operation for matching files.
func (*CachingBucketConfig) CacheExists ¶
func (cfg *CachingBucketConfig) CacheExists(configName string, cache Cache, matcher func(string) bool, existsTTL, doesntExistTTL time.Duration)
CacheExists configures caching of "Exists" operation for matching files. Negative values are cached as well.
func (*CachingBucketConfig) CacheGet ¶
func (cfg *CachingBucketConfig) CacheGet(configName string, cache Cache, matcher func(string) bool, maxCacheableSize int, contentTTL, existsTTL, doesntExistTTL time.Duration)
CacheGet configures caching of "Get" operation for matching files. Content of the object is cached, as well as whether object exists or not.
func (*CachingBucketConfig) CacheGetRange ¶
func (cfg *CachingBucketConfig) CacheGetRange(configName string, cache Cache, matcher func(string) bool, subrangeSize int64, attributesTTL, subrangeTTL time.Duration, maxSubRequests int)
CacheGetRange configures caching of "GetRange" operation. Subranges (aligned on subrange size) are cached individually. Since caching operation needs to know the object size to compute correct subranges, object size is cached as well. Single "GetRange" requests can result in multiple smaller GetRange sub-requests issued on the underlying bucket. MaxSubRequests specifies how many such subrequests may be issued. Values <= 0 mean there is no limit (requests for adjacent missing subranges are still merged).
func (*CachingBucketConfig) CacheIter ¶
func (cfg *CachingBucketConfig) CacheIter(configName string, cache Cache, matcher func(string) bool, ttl time.Duration, codec IterCodec)
CacheIter configures caching of "Iter" operation for matching directories.
func (*CachingBucketConfig) FindAttributesConfig ¶
func (cfg *CachingBucketConfig) FindAttributesConfig(name string) (string, *AttributesConfig)
func (*CachingBucketConfig) FindExistConfig ¶
func (cfg *CachingBucketConfig) FindExistConfig(name string) (string, *ExistsConfig)
func (*CachingBucketConfig) FindGetConfig ¶
func (cfg *CachingBucketConfig) FindGetConfig(name string) (string, *GetConfig)
func (*CachingBucketConfig) FindGetRangeConfig ¶
func (cfg *CachingBucketConfig) FindGetRangeConfig(name string) (string, *GetRangeConfig)
func (*CachingBucketConfig) FindIterConfig ¶
func (cfg *CachingBucketConfig) FindIterConfig(dir string) (string, *IterConfig)
func (*CachingBucketConfig) SetCacheImplementation ¶
func (cfg *CachingBucketConfig) SetCacheImplementation(c Cache)
SetCacheImplementation sets the value of Cache for all configurations.
type ExistsConfig ¶
type ExistsConfig struct { OperationConfig ExistsTTL time.Duration DoesntExistTTL time.Duration }
type GetConfig ¶
type GetConfig struct { ExistsConfig ContentTTL time.Duration MaxCacheableSize int }
type GetRangeConfig ¶
type Groupcache ¶
type Groupcache struct {
// contains filtered or unexported fields
}
func NewGroupcache ¶
func NewGroupcache(logger log.Logger, reg prometheus.Registerer, conf []byte, basepath string, r *route.Router, bucket objstore.Bucket, cfg *CachingBucketConfig) (*Groupcache, error)
NewGroupcache creates a new Groupcache instance.
func NewGroupcacheWithConfig ¶
func NewGroupcacheWithConfig(logger log.Logger, reg prometheus.Registerer, conf GroupcacheConfig, basepath string, r *route.Router, bucket objstore.Bucket, cfg *CachingBucketConfig) (*Groupcache, error)
NewGroupcacheWithConfig creates a new Groupcache instance with the given config.
func (*Groupcache) Name ¶
func (c *Groupcache) Name() string
type GroupcacheConfig ¶
type GroupcacheConfig struct { // Addresses of statically configured peers (repeatable). The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect store API servers through respective DNS lookups. // Typically, you'd want something like `dns+http://thanos-store:42/`. Peers []string `yaml:"peers"` // Address of ourselves in the peer list. This needs to be set to `http://external-ip:HTTP_PORT` // of the current instance. SelfURL string `yaml:"self_url"` // Maximum size of the hot in-memory cache. MaxSize model.Bytes `yaml:"max_size"` // Group's name. All of the instances need to be using the same group and point to the same bucket. GroupcacheGroup string `yaml:"groupcache_group"` // DNS SD resolver to use. DNSSDResolver dns.ResolverType `yaml:"dns_sd_resolver"` // How often we should resolve the addresses. DNSInterval time.Duration `yaml:"dns_interval"` // Timeout specifies the read/write timeout. Timeout time.Duration `yaml:"timeout"` }
GroupcacheConfig holds the in-memory cache config.
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
func NewInMemoryCache ¶
func NewInMemoryCache(name string, logger log.Logger, reg prometheus.Registerer, conf []byte) (*InMemoryCache, error)
NewInMemoryCache creates a new thread-safe LRU cache and ensures the total cache size approximately does not exceed maxBytes.
func NewInMemoryCacheWithConfig ¶
func NewInMemoryCacheWithConfig(name string, logger log.Logger, reg prometheus.Registerer, config InMemoryCacheConfig) (*InMemoryCache, error)
NewInMemoryCacheWithConfig creates a new thread-safe LRU cache and ensures the total cache size approximately does not exceed maxBytes.
func (*InMemoryCache) Fetch ¶
Fetch fetches multiple keys and returns a map containing cache hits In case of error, it logs and return an empty cache hits map.
func (*InMemoryCache) Name ¶
func (c *InMemoryCache) Name() string
type InMemoryCacheConfig ¶
type InMemoryCacheConfig struct { // MaxSize represents overall maximum number of bytes cache can contain. MaxSize model.Bytes `yaml:"max_size"` // MaxItemSize represents maximum size of single item. MaxItemSize model.Bytes `yaml:"max_item_size"` }
InMemoryCacheConfig holds the in-memory cache config.
type IterCodec ¶
type IterCodec interface { Encode(files []string) ([]byte, error) Decode(cachedData []byte) ([]string, error) }
Codec for encoding and decoding results of Iter call.
type IterConfig ¶
type IterConfig struct { OperationConfig TTL time.Duration Codec IterCodec }
Operation-specific configs.
type MemcachedCache ¶
type MemcachedCache struct {
// contains filtered or unexported fields
}
MemcachedCache is a memcached-based cache.
func NewMemcachedCache ¶
func NewMemcachedCache(name string, logger log.Logger, memcached cacheutil.RemoteCacheClient, reg prometheus.Registerer) *MemcachedCache
NewMemcachedCache makes a new MemcachedCache.
func (*MemcachedCache) Fetch ¶
Fetch fetches multiple keys and returns a map containing cache hits, along with a list of missing keys. In case of error, it logs and return an empty cache hits map.
func (*MemcachedCache) Name ¶
func (c *MemcachedCache) Name() string
type OperationConfig ¶
Generic config for single operation.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is a redis cache.
func NewRedisCache ¶
func NewRedisCache(name string, logger log.Logger, redisClient *cacheutil.RedisClient, reg prometheus.Registerer) *RedisCache
NewRedisCache makes a new RedisCache.
func (*RedisCache) Fetch ¶
Fetch fetches multiple keys and returns a map containing cache hits, along with a list of missing keys. In case of error, it logs and return an empty cache hits map.
func (*RedisCache) Name ¶
func (c *RedisCache) Name() string
type TracingCache ¶
type TracingCache struct {
// contains filtered or unexported fields
}
TracingCache includes Fetch operation in the traces.
func (TracingCache) Name ¶
func (t TracingCache) Name() string