cache

package
v0.79.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 6 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] interface {
	Get(key uint32, l Loader[V]) (V, error)
}

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 ConcurrentCache added in v0.78.0

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

func NewConcurrentCache added in v0.78.0

func NewConcurrentCache[V any](cleaner *Cleaner, metrics *Metrics) *ConcurrentCache[V]

func (*ConcurrentCache[V]) Cleanup added in v0.78.0

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

func (*ConcurrentCache[V]) Evict added in v0.78.0

func (c *ConcurrentCache[V]) Evict(key uint32)

func (*ConcurrentCache[V]) Get added in v0.78.0

func (c *ConcurrentCache[V]) Get(key uint32, l Loader[V]) (V, error)

func (*ConcurrentCache[V]) Release added in v0.78.0

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

func (*ConcurrentCache[V]) Released added in v0.78.0

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

func (*ConcurrentCache[V]) Reset added in v0.78.0

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

Reset is used in tests only

func (*ConcurrentCache[V]) SetGeneration added in v0.78.0

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

type Generation

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

func NewGeneration

func NewGeneration() *Generation

type Loader added in v0.78.0

type Loader[V any] interface {
	Load(key uint32) (value V, size int, err error)
}

type LoaderFunc added in v0.78.0

type LoaderFunc[V any] func(key uint32) (V, int, error)

func (LoaderFunc[V]) Load added in v0.78.0

func (f LoaderFunc[V]) Load(key uint32) (V, int, error)

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
	EntriesReleased prometheus.Counter
	MapsRecreated   prometheus.Counter
	MissLatency     prometheus.Counter
}

type Scan added in v0.78.0

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

Scan wrapper is used exclusively for compaction to prevent unnecessary evictions from cache.

func NewScan added in v0.78.0

func NewScan[V any]() *Scan[V]

func (*Scan[V]) Get added in v0.78.0

func (s *Scan[V]) Get(key uint32, l Loader[V]) (V, error)

type Session added in v0.78.0

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

Session is a wrapper for ConcurrentCache which stores local copies of [entry] via weak pointers.

func NewSession added in v0.78.0

func NewSession[V any](c *ConcurrentCache[V]) *Session[V]

func (*Session[V]) Get added in v0.78.0

func (s *Session[V]) Get(key uint32, l Loader[V]) (V, error)

Jump to

Keyboard shortcuts

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