cache

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Hit is a counter for cache hits.
	Hit = metrics.MustInt64().
		Counter(
			prometheus.BuildFQName(namespace, subsystem, "hit"),
			metric.WithDescription("The number of cache hits"),
		)
		// Miss is a counter for cache misses.
	Miss = metrics.MustInt64().
			Counter(
			prometheus.BuildFQName(namespace, subsystem, "miss"),
			metric.WithDescription("The number of cache misses"),
		)
		// Error is a counter for cache errors.
	Error = metrics.MustInt64().
			Counter(
			prometheus.BuildFQName(namespace, subsystem, "error"),
			metric.WithDescription("The number of times an error occurred reading or writing to the cache"),
		)
)

Functions

func Key added in v1.25.0

func Key(k string) string

func Observe

func Observe(ctx context.Context, typ string, counter metric.Int64Counter)

Observe adds one to the provided counter and records the cache type attribute supplied by typ.

Types

type Cacher

type Cacher interface {
	// Get retrieves a value from the cache, the bool indicates if the item was found
	Get(ctx context.Context, key string) ([]byte, bool, error)
	// Set sets a value in the cache
	Set(ctx context.Context, key string, value []byte) error
	// Delete removes a value from the cache
	Delete(ctx context.Context, key string) error
	fmt.Stringer
}

Cacher modifies and queries a cache

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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