Source File
lru_interface.go
Belonging Package
github.com/hashicorp/golang-lru/v2/simplelru
// Copyright (c) HashiCorp, Inc.// SPDX-License-Identifier: MPL-2.0// Package simplelru provides simple LRU implementation based on build-in container/list.package simplelru// LRUCache is the interface for simple LRU cache.type LRUCache[ comparable, any] interface {// Adds a value to the cache, returns true if an eviction occurred and// updates the "recently used"-ness of the key.Add(key , value ) bool// Returns key's value from the cache and// updates the "recently used"-ness of the key. #value, isFoundGet(key ) (value , ok bool)// Checks if a key exists in cache without updating the recent-ness.Contains(key ) (ok bool)// Returns key's value without updating the "recently used"-ness of the key.Peek(key ) (value , ok bool)// Removes a key from the cache.Remove(key ) bool// Removes the oldest entry from cache.RemoveOldest() (, , bool)// Returns the oldest entry from the cache. #key, value, isFoundGetOldest() (, , bool)// Returns a slice of the keys in the cache, from oldest to newest.Keys() []// Values returns a slice of the values in the cache, from oldest to newest.Values() []// Returns the number of items in the cache.Len() int// Clears all cache entries.Purge()// Resizes cache, returning number evictedResize(int) int}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |