package lru
import "golang.org/x/build/internal/lru"
Package lru implements an LRU cache.
Index ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache, safe for concurrent access.
func New ¶
New returns a new cache with the provided maximum items.
func (*Cache) Add ¶
func (c *Cache) Add(key, value interface{})
Add adds the provided key and value to the cache, evicting an old item if necessary.
func (*Cache) Get ¶
Get fetches the key's value from the cache. The ok result will be true if the item was found.
func (*Cache) Len ¶
Len returns the number of items in the cache.
func (*Cache) RemoveOldest ¶
func (c *Cache) RemoveOldest() (key, value interface{})
RemoveOldest removes the oldest item in the cache and returns its key and value. If the cache is empty, the empty string and nil are returned.
Source Files ¶
cache.go
- Version
- v0.0.0-20250421191922-3619c213cff3 (latest)
- Published
- Apr 21, 2025
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 3 months ago –
Tools for package owners.