metrictank: github.com/grafana/metrictank/publish/kafka/keycache Index | Files

package keycache

import "github.com/grafana/metrictank/publish/kafka/keycache"

Index

Package Files

cache.go keycache.go shard.go

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields
}

Cache is a single-tenant keycache it is sharded for 2 reasons: * more granular GC (eg. less latency perceived by caller) * mild space savings cause keys are 1 byte shorter We shard on the first byte of the metric key, which we assume is evenly distributed.

func NewCache Uses

func NewCache() *Cache

NewCache creates a new cache

func (*Cache) Clear Uses

func (c *Cache) Clear(i int) int

Clear resets the given shard

func (*Cache) Len Uses

func (c *Cache) Len() int

Len returns the length of the cache

func (*Cache) Touch Uses

func (c *Cache) Touch(key schema.Key) bool

Touch marks the key as seen and returns whether it was seen before

type KeyCache Uses

type KeyCache struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

KeyCache tracks for all orgs, which keys have been seen, and when was the last time

func NewKeyCache Uses

func NewKeyCache(clearInterval time.Duration) *KeyCache

NewKeyCache creates a new KeyCache each clearInterval, all shards will be wiped (one at a time, spread out over the interval)

func (*KeyCache) Len Uses

func (k *KeyCache) Len() int

Len returns the size across all orgs

func (*KeyCache) Touch Uses

func (k *KeyCache) Touch(key schema.MKey) bool

Touch marks the key as seen and returns whether it was seen before callers should assure that t >= ref and t-ref <= 42 hours

type Shard Uses

type Shard struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Shard tracks which SubKey's have been seen since the last prune

func NewShard Uses

func NewShard() Shard

NewShard creates a new shard

func (*Shard) Len Uses

func (s *Shard) Len() int

Len returns the length of the shard

func (*Shard) Reset Uses

func (s *Shard) Reset()

Reset resets the shard, making it empty

func (*Shard) Touch Uses

func (s *Shard) Touch(key schema.Key) bool

Touch marks the key as seen and returns whether it was seen before

type SubKey Uses

type SubKey [15]byte

SubKey is the last 15 bytes of a 16 byte Key We can track Key-identified metrics with a SubKey because we shard by the first byte of the Key.

Package keycache imports 3 packages (graph) and is imported by 3 packages. Updated 2020-01-24. Refresh now. Tools for package owners.