cache

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[V any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[V any](cleaner *Cleaner, metrics *Metrics) *Cache[V]

func (*Cache[V]) Cleanup

func (c *Cache[V]) Cleanup() uint64

func (*Cache[V]) Get

func (c *Cache[V]) Get(key uint32, fn func() (V, int)) V

func (*Cache[V]) GetWithError

func (c *Cache[V]) GetWithError(key uint32, fn func() (V, int, error)) (V, error)

func (*Cache[V]) Release

func (c *Cache[V]) Release()

func (*Cache[V]) Released

func (c *Cache[V]) Released() bool

func (*Cache[V]) Reset

func (c *Cache[V]) Reset(generation *Generation)

Reset is used in tests only

func (*Cache[V]) SetGeneration

func (c *Cache[V]) SetGeneration(generation *Generation)

type CleanStat

type CleanStat struct {
	TotalSize      uint64
	GensTotal      int
	BucketsTotal   int
	GensCleaned    int
	OldestGenTime  int64
	SizeToClean    uint64
	BytesReleased  uint64
	BucketsCleaned int
}

type Cleaner

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

func NewCleaner

func NewCleaner(sizeLimit uint64, metrics *CleanerMetrics) *Cleaner

func (*Cleaner) AddBucket

func (c *Cleaner) AddBucket(b bucket)

func (*Cleaner) CleanEmptyGenerations

func (c *Cleaner) CleanEmptyGenerations() int

func (*Cleaner) Cleanup

func (c *Cleaner) Cleanup(stat *CleanStat) bool

func (*Cleaner) ReleaseBuckets

func (c *Cleaner) ReleaseBuckets() int

func (*Cleaner) Reset

func (c *Cleaner) Reset()

Reset is used in tests only

func (*Cleaner) Rotate

func (c *Cleaner) Rotate() (bool, uint64)

func (*Cleaner) SizeLimit

func (c *Cleaner) SizeLimit() uint64

type CleanerMetrics

type CleanerMetrics struct {
	Oldest prometheus.Gauge

	AddBuckets prometheus.Counter
	DelBuckets prometheus.Counter

	CleanGenerations  prometheus.Counter
	ChangeGenerations prometheus.Counter
}

func (*CleanerMetrics) BucketsInc

func (m *CleanerMetrics) BucketsInc()

func (*CleanerMetrics) BucketsSub

func (m *CleanerMetrics) BucketsSub(cnt int)

func (*CleanerMetrics) GenerationsInc

func (m *CleanerMetrics) GenerationsInc()

func (*CleanerMetrics) GenerationsSub

func (m *CleanerMetrics) GenerationsSub(cnt int)

func (*CleanerMetrics) OldestSet

func (m *CleanerMetrics) OldestSet(nsec int64)

type Generation

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

func NewGeneration

func NewGeneration() *Generation

type Metrics

type Metrics struct {
	HitsTotal       prometheus.Counter
	MissTotal       prometheus.Counter
	PanicsTotal     prometheus.Counter
	LockWaitsTotal  prometheus.Counter
	WaitsTotal      prometheus.Counter
	ReattemptsTotal prometheus.Counter
	SizeRead        prometheus.Counter
	SizeOccupied    prometheus.Counter
	SizeReleased    prometheus.Counter
	MapsRecreated   prometheus.Counter
	MissLatency     prometheus.Counter
}

Jump to

Keyboard shortcuts

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