lru

package
v1.9.7-0...-24da1cd Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] struct {
	*lru.Cache[K, V]
	// contains filtered or unexported fields
}

Cache is a wrapper around hashicorp lru but with metric for Get

func New

func New[K comparable, V any](metricName string, size int) (*Cache[K, V], error)

func NewWithEvict

func NewWithEvict[K comparable, V any](metricName string, size int, fn func(K, V)) (*Cache[K, V], error)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(k K) (V, bool)

type CacheWithTTL

type CacheWithTTL[K comparable, V any] struct {
	*expirable.LRU[K, V]
	// contains filtered or unexported fields
}

func NewWithTTL

func NewWithTTL[K comparable, V any](metricName string, size int, ttl time.Duration) *CacheWithTTL[K, V]

func (*CacheWithTTL[K, V]) Get

func (c *CacheWithTTL[K, V]) Get(k K) (V, bool)

Jump to

Keyboard shortcuts

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