cache

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 14 Imported by: 5 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	rules.Matcher

	// Register sets the source for a given namespace.
	Register(namespace []byte, source rules.Matcher)

	// Refresh clears the cached results for the given source for a given namespace.
	Refresh(namespace []byte, source rules.Matcher)

	// Unregister deletes the cached results for a given namespace.
	Unregister(namespace []byte)

	// Close closes the cache.
	Close() error
}

Cache caches the rule matching result associated with metrics.

func NewCache

func NewCache(opts Options) Cache

NewCache creates a new cache.

type Configuration

type Configuration struct {
	Capacity          int           `yaml:"capacity"`
	FreshDuration     time.Duration `yaml:"freshDuration"`
	StutterDuration   time.Duration `yaml:"stutterDuration"`
	EvictionBatchSize int           `yaml:"evictionBatchSize"`
	DeletionBatchSize int           `yaml:"deletionBatchSize"`
}

Configuration is config used to create a Cache.

func (*Configuration) NewCache

func (cfg *Configuration) NewCache(
	clockOpts clock.Options,
	instrumentOpts instrument.Options,
) Cache

NewCache creates a Cache.

type InvalidationMode

type InvalidationMode int

InvalidationMode is the invalidation mode.

const (
	// InvalidateOne only invalidates a single invalid entry as needed.
	InvalidateOne InvalidationMode = iota

	// InvalidateAll invalidates all entries as long as one entry is invalid.
	InvalidateAll
)

type Options

type Options interface {
	// SetClockOptions sets the clock options.
	SetClockOptions(value clock.Options) Options

	// ClockOptions returns the clock options.
	ClockOptions() clock.Options

	// SetInstrumentOptions sets the instrument options.
	SetInstrumentOptions(value instrument.Options) Options

	// InstrumentOptions returns the instrument options.
	InstrumentOptions() instrument.Options

	// SetCapacity sets the cache capacity.
	SetCapacity(value int) Options

	// Capacity returns the cache capacity.
	Capacity() int

	// SetFreshDuration sets the entry fresh duration.
	SetFreshDuration(value time.Duration) Options

	// FreshDuration returns the fresh duration.
	FreshDuration() time.Duration

	// SetStutterDuration sets the entry stutter duration.
	SetStutterDuration(value time.Duration) Options

	// StutterDuration returns the entry stutter duration.
	StutterDuration() time.Duration

	// SetEvictionBatchSize sets the eviction batch size.
	SetEvictionBatchSize(value int) Options

	// EvictionBatchSize returns the eviction batch size.
	EvictionBatchSize() int

	// SetDeletionBatchSize sets the deletion batch size.
	SetDeletionBatchSize(value int) Options

	// DeletionBatchSize returns the deletion batch size.
	DeletionBatchSize() int

	// SetInvalidationMode sets the invalidation mode.
	SetInvalidationMode(value InvalidationMode) Options

	// InvalidationMode returns the invalidation mode.
	InvalidationMode() InvalidationMode

	// NamespaceResolver returns the namespace Resolver.
	NamespaceResolver() namespace.Resolver

	// SetNamespaceResolver set the NamespaceResolver.
	SetNamespaceResolver(value namespace.Resolver) Options
}

Options provide a set of cache options.

func NewOptions

func NewOptions() Options

NewOptions creates a new set of options.

Jump to

Keyboard shortcuts

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