cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// ForwardMatch returns the rule matching result associated with a metric id
	// between [fromNanos, toNanos).
	ForwardMatch(namespace, id []byte, fromNanos, toNanos int64) rules.MatchResult

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

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

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

Options provide a set of cache options.

func NewOptions

func NewOptions() Options

NewOptions creates a new set of options.

type Source

type Source interface {
	// ForwardMatch returns the match result for a given id within time range
	// [fromNanos, toNanos).
	ForwardMatch(id []byte, fromNanos, toNanos int64) rules.MatchResult
}

Source is a datasource providing match results.

Jump to

Keyboard shortcuts

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