Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 Package lru implements an LRU cache. It is based on Google Groupcache's LRU implementation, distributed under Apache License 2.0 in the following repository: https://github.com/golang/groupcache
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache. It is not safe for concurrent access. This cache is not limited in size, but allows resizing it by means of the RemoveUntilLen(int) function
func New ¶
func New() *Cache
New creates a new Cache. The cache has no limit and it's assumed that eviction is done by the caller.
func (*Cache) RemoveOldest ¶
func (c *Cache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
func (*Cache) RemoveUntilLen ¶
RemoveUntilLen removes the oldest entries until the cache reaches the given length.
type Key ¶
type Key interface{}
A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators