Version: v1.4.2 Latest Latest

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 14 Imported by: 8




This section is empty.


This section is empty.


This section is empty.


type Cache

type Cache interface {

	// 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.

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