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 LRU ¶ added in v1.3.0
type LRU[K comparable, V any] struct { // contains filtered or unexported fields }
LRU is a plain LRU cache.
func New ¶ added in v1.3.0
func New[K comparable, V any](capacity int, fn func(K) (V, error)) *LRU[K, V]
New 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.
type SyncLRU ¶ added in v1.3.0
type SyncLRU[K comparable, V any] struct { // contains filtered or unexported fields }
SyncLRU is a LRU cache for concurrent use.
func NewSyncLRU ¶ added in v1.3.0
func NewSyncLRU[K comparable, V any](capacity int, fn func(K) (V, error)) *SyncLRU[K, V]
NewSyncLRU 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.