Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNoopCache added in v0.20.0

func NewNoopCache[K comparable, V any]() *noopCache[K, V]

Types

type CacheWithTTLOptions added in v0.20.0

type CacheWithTTLOptions struct {
	UpdateDeadlineOnGet bool
	RemoveExpiredOnAdd  bool
}

type LRUCache added in v0.20.0

type LRUCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewLRUCache added in v0.20.0

func NewLRUCache[K comparable, V any](reg prometheus.Registerer, maxEntries int) *LRUCache[K, V]

func (*LRUCache[K, V]) Add added in v0.20.0

func (c *LRUCache[K, V]) Add(key K, value V)

func (*LRUCache[K, V]) Close added in v0.20.0

func (c *LRUCache[K, V]) Close() error

func (*LRUCache[K, V]) Get added in v0.20.0

func (c *LRUCache[K, V]) Get(key K) (V, bool)

func (*LRUCache[K, V]) Peek added in v0.20.0

func (c *LRUCache[K, V]) Peek(key K) (V, bool)

Peek returns the value associated with key without updating the "recently used"-ness of that key.

func (*LRUCache[K, V]) Purge added in v0.20.0

func (c *LRUCache[K, V]) Purge()

func (*LRUCache[K, V]) Remove added in v0.20.0

func (c *LRUCache[K, V]) Remove(key K)

type LRUCacheWithEvictionTTL added in v0.20.0

type LRUCacheWithEvictionTTL[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewLRUCacheWithEvictionTTL added in v0.20.0

func NewLRUCacheWithEvictionTTL[K comparable, V any](reg prometheus.Registerer, maxEntries int, ttl time.Duration, onEvictedCallback func(k K, v V)) *LRUCacheWithEvictionTTL[K, V]

func (*LRUCacheWithEvictionTTL[K, V]) Add added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Add(key K, value V)

func (*LRUCacheWithEvictionTTL[K, V]) Close added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Close() error

func (*LRUCacheWithEvictionTTL[K, V]) Get added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Get(key K) (V, bool)

func (*LRUCacheWithEvictionTTL[K, V]) Peek added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Peek(key K) (V, bool)

func (*LRUCacheWithEvictionTTL[K, V]) Purge added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Purge()

func (*LRUCacheWithEvictionTTL[K, V]) Remove added in v0.20.0

func (c *LRUCacheWithEvictionTTL[K, V]) Remove(key K)

type LRUCacheWithTTL added in v0.20.0

type LRUCacheWithTTL[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewLRUCacheWithTTL added in v0.20.0

func NewLRUCacheWithTTL[K comparable, V any](reg prometheus.Registerer, maxEntries int, ttl time.Duration, opts ...CacheWithTTLOptions) *LRUCacheWithTTL[K, V]

func (*LRUCacheWithTTL[K, V]) Add added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Add(key K, value V)

func (*LRUCacheWithTTL[K, V]) Close added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Close() error

func (*LRUCacheWithTTL[K, V]) Get added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Get(key K) (V, bool)

func (*LRUCacheWithTTL[K, V]) Peek added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Peek(key K) (V, bool)

func (*LRUCacheWithTTL[K, V]) Purge added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Purge()

func (*LRUCacheWithTTL[K, V]) Remove added in v0.20.0

func (c *LRUCacheWithTTL[K, V]) Remove(key K)

type LRUWithEviction added in v0.20.0

type LRUWithEviction[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewLRUWithEviction added in v0.20.0

func NewLRUWithEviction[K comparable, V any](reg prometheus.Registerer, maxEntries int, onEvictedCallback func(k K, v V)) (*LRUWithEviction[K, V], error)

NewLRUWithEviction returns a new CacheWithEviction with the given maxEntries.

func (*LRUWithEviction[K, V]) Add added in v0.20.0

func (c *LRUWithEviction[K, V]) Add(key K, value V)

Add adds a value to the cache.

func (*LRUWithEviction[K, V]) Close added in v0.20.0

func (c *LRUWithEviction[K, V]) Close()

Close is used to close the underlying LRU by also purging it.

func (*LRUWithEviction[K, V]) Get added in v0.20.0

func (c *LRUWithEviction[K, V]) Get(key K) (V, bool)

Get looks up a key's value from the cache.

func (*LRUWithEviction[K, V]) Peek added in v0.20.0

func (c *LRUWithEviction[K, V]) Peek(key K) (V, bool)

Peek returns the value associated with key without updating the "recently used"-ness of that key.

func (*LRUWithEviction[K, V]) Purge added in v0.20.0

func (c *LRUWithEviction[K, V]) Purge()

Purge is used to completely clear the cache.

func (*LRUWithEviction[K, V]) Remove added in v0.20.0

func (c *LRUWithEviction[K, V]) Remove(key K)

Remove removes the provided key from the cache.

type LoaderFunc added in v0.20.0

type LoaderFunc[K comparable, V any] func(K) (V, error)

type LoadingLRUCacheWithTTL added in v0.20.0

type LoadingLRUCacheWithTTL[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewLoadingLRUCacheWithTTL added in v0.20.0

func NewLoadingLRUCacheWithTTL[K comparable, V any](reg prometheus.Registerer, maxEntries int, ttl time.Duration, loader LoaderFunc[K, V]) *LoadingLRUCacheWithTTL[K, V]

func NewLoadingOnceCache added in v0.20.0

func NewLoadingOnceCache[K comparable, V any](reg prometheus.Registerer, maxEntries int, ttl time.Duration, loader LoaderFunc[K, V]) *LoadingLRUCacheWithTTL[K, V]

NewLoadingOnceCache creates a LoadingCache that allows only one loading operation at a time.

The returned LoadingCache will call the loader function to load entries on cache misses. However, it will use a singleflight.Group to ensure only one concurrent call to the loader is made for a given key. This can be used to prevent redundant loading of data on cache misses when multiple concurrent requests are made for the same key.

func (*LoadingLRUCacheWithTTL[K, V]) Close added in v0.20.0

func (c *LoadingLRUCacheWithTTL[K, V]) Close() error

func (*LoadingLRUCacheWithTTL[K, V]) Get added in v0.20.0

func (c *LoadingLRUCacheWithTTL[K, V]) Get(key K) (V, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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