cache

package
v6.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TagMapKey

func TagMapKey(tags map[string]string) uint64

TagMapKey generates a new key based on tags.

Types

type StringInterner

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

StringInterner interns strings.

func NewStringInterner

func NewStringInterner() *StringInterner

NewStringInterner creates a new StringInterner.

func (*StringInterner) Intern

func (i *StringInterner) Intern(s string) string

Intern interns s.

type TagCache

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

TagCache is an identity.Accumulator-based tag cache with LRU eviction.

func NewTagCache

func NewTagCache() *TagCache

NewTagCache creates a new TagCache with default settings.

func NewTagCacheWithOptions

func NewTagCacheWithOptions(opts TagCacheOptions) *TagCache

NewTagCacheWithOptions creates a new TagCache with specified options.

func (*TagCache) CleanupExpired

func (c *TagCache) CleanupExpired() int

CleanupExpired removes expired entries (useful for periodic cleanup).

func (*TagCache) Clear

func (c *TagCache) Clear()

Clear removes all entries from the cache.

func (*TagCache) Get

func (c *TagCache) Get(key uint64) ([]m3thrift.MetricTag, bool)

Get returns the cached value for key.

func (*TagCache) Len

func (c *TagCache) Len() int

Len returns the size of the cache.

func (*TagCache) Set

func (c *TagCache) Set(key uint64, tslice []m3thrift.MetricTag) []m3thrift.MetricTag

Set attempts to set the value of key as tslice, returning either tslice or the pre-existing value if found.

func (*TagCache) Stats

func (c *TagCache) Stats() (hits, misses, evictions int64, hitRate float64)

Stats returns cache statistics.

type TagCacheOptions

type TagCacheOptions struct {
	MaxSize    int   // Maximum number of entries (default: 10000)
	TTLSeconds int64 // TTL in seconds, 0 means no TTL (default: 3600 = 1 hour)
}

TagCacheOptions configures the TagCache behavior

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL