Documentation ¶
Overview ¶
Package lru implements asynchronous LRU cache.
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 { // contains filtered or unexported fields }
Cache is a LRU cache.
func NewCache ¶
func NewCache[K comparable, V any](capacity int, f func(K) (V, error)) *Cache[K, V]
NewCache creates an LRU cache with the specified capacity. f is a callback function for getting a value by key, which is called if there is no value in the cache. The callback function will be called once for concurrent Get requests with the same key.
Click to show internal directories.
Click to hide internal directories.