caching

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

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

LRUCache wraps hashicorp *lru.Cache and tracks cache metrics

func NewLRUCache

func NewLRUCache(m Metrics, label string, maxSize int) *LRUCache

NewLRUCache creates a LRU cache with the given metrics, labeling the cache adds/gets. Metrics are optional: no metrics will be tracked if m == nil.

func (*LRUCache) Add

func (c *LRUCache) Add(key, value any) (evicted bool)

func (*LRUCache) Get

func (c *LRUCache) Get(key any) (value any, ok bool)

type Metrics

type Metrics interface {
	CacheAdd(label string, cacheSize int, evicted bool)
	CacheGet(label string, hit bool)
}

Jump to

Keyboard shortcuts

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