Documentation
¶
Index ¶
- Variables
- func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger log.Logger, ...) (objstore.InstrumentedBucket, error)
- type BucketCacheProvider
- type CachingBucket
- func (cb *CachingBucket) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
- func (cb *CachingBucket) Exists(ctx context.Context, name string) (bool, error)
- func (cb *CachingBucket) Get(ctx context.Context, name string) (io.ReadCloser, error)
- func (cb *CachingBucket) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
- func (cb *CachingBucket) IsObjNotFoundErr(err error) bool
- func (cb *CachingBucket) Iter(ctx context.Context, dir string, f func(string) error, ...) error
- func (cb *CachingBucket) Name() string
- func (cb *CachingBucket) ReaderWithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.BucketReader
- func (cb *CachingBucket) WithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.Bucket
- type CachingWithBackendConfig
- type InMemoryIndexCache
- func (c *InMemoryIndexCache) FetchMultiPostings(_ context.Context, blockID ulid.ULID, keys []labels.Label) (hits map[labels.Label][]byte, misses []labels.Label)
- func (c *InMemoryIndexCache) FetchMultiSeries(_ context.Context, blockID ulid.ULID, ids []storage.SeriesRef) (hits map[storage.SeriesRef][]byte, misses []storage.SeriesRef)
- func (c *InMemoryIndexCache) StorePostings(_ context.Context, blockID ulid.ULID, l labels.Label, v []byte)
- func (c *InMemoryIndexCache) StoreSeries(_ context.Context, blockID ulid.ULID, id storage.SeriesRef, v []byte)
- type InMemoryIndexCacheConfig
- type IndexCache
- type IndexCacheConfig
- type IndexCacheProvider
- type JSONIterCodec
- type RemoteIndexCache
- func (c *RemoteIndexCache) FetchMultiPostings(ctx context.Context, blockID ulid.ULID, lbls []labels.Label) (hits map[labels.Label][]byte, misses []labels.Label)
- func (c *RemoteIndexCache) FetchMultiSeries(ctx context.Context, blockID ulid.ULID, ids []storage.SeriesRef) (hits map[storage.SeriesRef][]byte, misses []storage.SeriesRef)
- func (c *RemoteIndexCache) StorePostings(ctx context.Context, blockID ulid.ULID, l labels.Label, v []byte)
- func (c *RemoteIndexCache) StoreSeries(ctx context.Context, blockID ulid.ULID, id storage.SeriesRef, v []byte)
Constants ¶
This section is empty.
Variables ¶
var (
DefaultInMemoryIndexCacheConfig = InMemoryIndexCacheConfig{
MaxSize: 250 * 1024 * 1024,
MaxItemSize: 125 * 1024 * 1024,
}
)
Functions ¶
func NewCachingBucketFromYaml ¶
func NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger log.Logger, reg prometheus.Registerer, r *route.Router) (objstore.InstrumentedBucket, error)
NewCachingBucketFromYaml uses YAML configuration to create new caching bucket.
Types ¶
type BucketCacheProvider ¶
type BucketCacheProvider string
BucketCacheProvider is a type used to evaluate all bucket cache providers.
const ( InMemoryBucketCacheProvider BucketCacheProvider = "IN-MEMORY" // In-memory cache-provider for caching bucket. MemcachedBucketCacheProvider BucketCacheProvider = "MEMCACHED" // Memcached cache-provider for caching bucket. RedisBucketCacheProvider BucketCacheProvider = "REDIS" // Redis cache-provider for caching bucket. GroupcacheBucketCacheProvider BucketCacheProvider = "GROUPCACHE" // Groupcache cache-provider for caching bucket. )
type CachingBucket ¶
CachingBucket implementation that provides some caching features, based on passed configuration.
func NewCachingBucket ¶
func NewCachingBucket(b objstore.Bucket, cfg *cache.CachingBucketConfig, logger log.Logger, reg prometheus.Registerer) (*CachingBucket, error)
NewCachingBucket creates new caching bucket with provided configuration. Configuration should not be changed after creating caching bucket.
func (*CachingBucket) Attributes ¶
func (cb *CachingBucket) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error)
func (*CachingBucket) Get ¶
func (cb *CachingBucket) Get(ctx context.Context, name string) (io.ReadCloser, error)
func (*CachingBucket) GetRange ¶
func (cb *CachingBucket) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error)
func (*CachingBucket) IsObjNotFoundErr ¶
func (cb *CachingBucket) IsObjNotFoundErr(err error) bool
func (*CachingBucket) Iter ¶
func (cb *CachingBucket) Iter(ctx context.Context, dir string, f func(string) error, options ...objstore.IterOption) error
func (*CachingBucket) Name ¶
func (cb *CachingBucket) Name() string
func (*CachingBucket) ReaderWithExpectedErrs ¶
func (cb *CachingBucket) ReaderWithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.BucketReader
func (*CachingBucket) WithExpectedErrs ¶
func (cb *CachingBucket) WithExpectedErrs(expectedFunc objstore.IsOpFailureExpectedFunc) objstore.Bucket
type CachingWithBackendConfig ¶
type CachingWithBackendConfig struct {
Type BucketCacheProvider `yaml:"type"`
BackendConfig interface{} `yaml:"config"`
// Basic unit used to cache chunks.
ChunkSubrangeSize int64 `yaml:"chunk_subrange_size"`
// Maximum number of GetRange requests issued by this bucket for single GetRange call. Zero or negative value = unlimited.
MaxChunksGetRangeRequests int `yaml:"max_chunks_get_range_requests"`
MetafileMaxSize model.Bytes `yaml:"metafile_max_size"`
// TTLs for various cache items.
ChunkObjectAttrsTTL time.Duration `yaml:"chunk_object_attrs_ttl"`
ChunkSubrangeTTL time.Duration `yaml:"chunk_subrange_ttl"`
// How long to cache result of Iter call in root directory.
BlocksIterTTL time.Duration `yaml:"blocks_iter_ttl"`
// Config for Exists and Get operations for metadata files.
MetafileExistsTTL time.Duration `yaml:"metafile_exists_ttl"`
MetafileDoesntExistTTL time.Duration `yaml:"metafile_doesnt_exist_ttl"`
MetafileContentTTL time.Duration `yaml:"metafile_content_ttl"`
}
CachingWithBackendConfig is a configuration of caching bucket used by Store component.
func (*CachingWithBackendConfig) Defaults ¶
func (cfg *CachingWithBackendConfig) Defaults()
type InMemoryIndexCache ¶
type InMemoryIndexCache struct {
// contains filtered or unexported fields
}
func NewInMemoryIndexCache ¶
func NewInMemoryIndexCache(logger log.Logger, reg prometheus.Registerer, conf []byte) (*InMemoryIndexCache, error)
NewInMemoryIndexCache creates a new thread-safe LRU cache for index entries and ensures the total cache size approximately does not exceed maxBytes.
func NewInMemoryIndexCacheWithConfig ¶
func NewInMemoryIndexCacheWithConfig(logger log.Logger, reg prometheus.Registerer, config InMemoryIndexCacheConfig) (*InMemoryIndexCache, error)
NewInMemoryIndexCacheWithConfig creates a new thread-safe LRU cache for index entries and ensures the total cache size approximately does not exceed maxBytes.
func (*InMemoryIndexCache) FetchMultiPostings ¶
func (c *InMemoryIndexCache) FetchMultiPostings(_ context.Context, blockID ulid.ULID, keys []labels.Label) (hits map[labels.Label][]byte, misses []labels.Label)
FetchMultiPostings fetches multiple postings - each identified by a label - and returns a map containing cache hits, along with a list of missing keys.
func (*InMemoryIndexCache) FetchMultiSeries ¶
func (c *InMemoryIndexCache) FetchMultiSeries(_ context.Context, blockID ulid.ULID, ids []storage.SeriesRef) (hits map[storage.SeriesRef][]byte, misses []storage.SeriesRef)
FetchMultiSeries fetches multiple series - each identified by ID - from the cache and returns a map containing cache hits, along with a list of missing IDs.
func (*InMemoryIndexCache) StorePostings ¶
func (c *InMemoryIndexCache) StorePostings(_ context.Context, blockID ulid.ULID, l labels.Label, v []byte)
StorePostings sets the postings identified by the ulid and label to the value v, if the postings already exists in the cache it is not mutated.
func (*InMemoryIndexCache) StoreSeries ¶
func (c *InMemoryIndexCache) StoreSeries(_ context.Context, blockID ulid.ULID, id storage.SeriesRef, v []byte)
StoreSeries sets the series identified by the ulid and id to the value v, if the series already exists in the cache it is not mutated.
type InMemoryIndexCacheConfig ¶
type InMemoryIndexCacheConfig 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"`
}
InMemoryIndexCacheConfig holds the in-memory index cache config.
type IndexCache ¶
type IndexCache interface {
// StorePostings stores postings for a single series.
StorePostings(ctx context.Context, blockID ulid.ULID, l labels.Label, v []byte)
// FetchMultiPostings fetches multiple postings - each identified by a label -
// and returns a map containing cache hits, along with a list of missing keys.
FetchMultiPostings(ctx context.Context, blockID ulid.ULID, keys []labels.Label) (hits map[labels.Label][]byte, misses []labels.Label)
// StoreSeries stores a single series.
StoreSeries(ctx context.Context, blockID ulid.ULID, id storage.SeriesRef, v []byte)
// FetchMultiSeries fetches multiple series - each identified by ID - from the cache
// and returns a map containing cache hits, along with a list of missing IDs.
FetchMultiSeries(ctx context.Context, blockID ulid.ULID, ids []storage.SeriesRef) (hits map[storage.SeriesRef][]byte, misses []storage.SeriesRef)
}
IndexCache is the interface exported by index cache backends.
func NewIndexCache ¶
func NewIndexCache(logger log.Logger, confContentYaml []byte, reg prometheus.Registerer) (IndexCache, error)
NewIndexCache initializes and returns new index cache.
type IndexCacheConfig ¶
type IndexCacheConfig struct {
Type IndexCacheProvider `yaml:"type"`
Config interface{} `yaml:"config"`
}
IndexCacheConfig specifies the index cache config.
type IndexCacheProvider ¶
type IndexCacheProvider string
const ( INMEMORY IndexCacheProvider = "IN-MEMORY" MEMCACHED IndexCacheProvider = "MEMCACHED" REDIS IndexCacheProvider = "REDIS" )
type JSONIterCodec ¶
type JSONIterCodec struct{}
JSONIterCodec encodes iter results into JSON. Suitable for root dir.
type RemoteIndexCache ¶
type RemoteIndexCache struct {
// contains filtered or unexported fields
}
RemoteIndexCache is a memcached-based index cache.
func NewMemcachedIndexCache ¶
func NewMemcachedIndexCache(logger log.Logger, memcached cacheutil.RemoteCacheClient, reg prometheus.Registerer) (*RemoteIndexCache, error)
NewMemcachedIndexCache is alias NewRemoteIndexCache for compatible.
func NewRemoteIndexCache ¶
func NewRemoteIndexCache(logger log.Logger, cacheClient cacheutil.RemoteCacheClient, reg prometheus.Registerer) (*RemoteIndexCache, error)
NewRemoteIndexCache makes a new RemoteIndexCache.
func (*RemoteIndexCache) FetchMultiPostings ¶
func (c *RemoteIndexCache) FetchMultiPostings(ctx context.Context, blockID ulid.ULID, lbls []labels.Label) (hits map[labels.Label][]byte, misses []labels.Label)
FetchMultiPostings fetches multiple postings - each identified by a label - 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 (*RemoteIndexCache) FetchMultiSeries ¶
func (c *RemoteIndexCache) FetchMultiSeries(ctx context.Context, blockID ulid.ULID, ids []storage.SeriesRef) (hits map[storage.SeriesRef][]byte, misses []storage.SeriesRef)
FetchMultiSeries fetches multiple series - each identified by ID - from the cache and returns a map containing cache hits, along with a list of missing IDs. In case of error, it logs and return an empty cache hits map.
func (*RemoteIndexCache) StorePostings ¶
func (c *RemoteIndexCache) StorePostings(ctx context.Context, blockID ulid.ULID, l labels.Label, v []byte)
StorePostings sets the postings identified by the ulid and label to the value v. The function enqueues the request and returns immediately: the entry will be asynchronously stored in the cache.
func (*RemoteIndexCache) StoreSeries ¶
func (c *RemoteIndexCache) StoreSeries(ctx context.Context, blockID ulid.ULID, id storage.SeriesRef, v []byte)
StoreSeries sets the series identified by the ulid and id to the value v. The function enqueues the request and returns immediately: the entry will be asynchronously stored in the cache.