Discover Packages
github.com/wzshiming/lru
package
module
Version:
v0.1.0
Opens a new window with list of versions in this module.
Published: Nov 14, 2022
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 2 modules, 2 packages
The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
Opens a new window with list of known importers.
README
Documentation
¶
type LRU
func (l *LRU[K, V]) Cap() int
func (l *LRU[K, V]) Close()
func (l *LRU[K, V]) Contains(key K) bool
func (l *LRU[K, V]) Delete(key K) (prev V, deleted bool)
func (l *LRU[K, V]) Evict() (key K, value V, evicted bool)
func (l *LRU[K, V]) ForEach(iter func(key K, value V) bool)
func (l *LRU[K, V]) Get(key K) (value V, ok bool)
func (l *LRU[K, V]) Keys() []K
func (l *LRU[K, V]) Len() int
func (l *LRU[K, V]) Peek(key K) (value V, ok bool)
func (l *LRU[K, V]) Put(key K, value V) (prev V, replaced bool)
func (l *LRU[K, V]) Resize(size int)
func (l *LRU[K, V]) Values() []V
LRU is a thread-safe fixed size LRU cache.
NewLRU returns a new LRU of the given size.
Cap returns the capacity of the lru cache
func (l *LRU [K, V]) Close()
Close closes the cache.
func (l *LRU [K, V]) Contains(key K) bool
Contains returns true if the key exists.
func (l *LRU [K, V]) Delete(key K) (prev V, deleted bool )
Delete a value for a key
func (l *LRU [K, V]) Evict() (key K, value V, evicted bool )
Evict evicts the least recently used item from the cache.
func (l *LRU [K, V]) ForEach(iter func(key K, value V) bool )
ForEach iterates over the cache, calling f for each item.
func (l *LRU [K, V]) Get(key K) (value V, ok bool )
Get returns a value for key and mark it as most recently used.
func (l *LRU [K, V]) Keys() []K
Keys returns a slice of the keys in the cache.
Len returns the length of the lru cache
func (l *LRU [K, V]) Peek(key K) (value V, ok bool )
Peek returns the value for key without marking it as most recently used.
func (l *LRU [K, V]) Put(key K, value V) (prev V, replaced bool )
Put sets the value for the specified key.
func (l *LRU [K, V]) Resize(size int )
Resize resizes the cache to the specified size.
func (l *LRU [K, V]) Values() []V
Values returns a slice of the values in the cache.
Source Files
¶
Directories
¶
internal
Click to show internal directories.
Click to hide internal directories.