Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
DefaultInMemoryCacheConfig = InMemoryCacheConfig{
MaxSize: 250 * 1024 * 1024,
MaxItemSize: 125 * 1024 * 1024,
}
)
Functions ¶
This section is empty.
Types ¶
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 ¶ added in v0.14.0
type InMemoryCache ¶ added in v0.19.0
type InMemoryCache struct {
// contains filtered or unexported fields
}
func NewInMemoryCache ¶ added in v0.19.0
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 ¶ added in v0.19.0
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 ¶ added in v0.19.0
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 ¶ added in v0.24.0
func (c *InMemoryCache) Name() string
type InMemoryCacheConfig ¶ added in v0.19.0
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 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.MemcachedClient, 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 ¶ added in v0.24.0
func (c *MemcachedCache) Name() string
type TracingCache ¶ added in v0.14.0
type TracingCache struct {
// contains filtered or unexported fields
}
TracingCache includes Fetch operation in the traces.
func (TracingCache) Name ¶ added in v0.24.0
func (t TracingCache) Name() string