Documentation
¶
Overview ¶
Package boundedmap is a map with a capacity: once full, putting a new key evicts the least recently used one. Plugins that keep per-principal or per-address state in memory use it so that state cannot grow without bound over the life of a process.
A Map is not safe for concurrent use; callers hold their own lock, as they already did around the plain maps this replaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map holds at most capacity entries in least-recently-used order.
func New ¶
func New[K comparable, V any](capacity int) *Map[K, V]
New returns an empty map that holds at most capacity entries. A capacity of zero or less means no bound, for callers that opt out.
func (*Map[K, V]) Delete ¶
func (m *Map[K, V]) Delete(key K)
Delete removes key. Deleting an absent key does nothing.
Click to show internal directories.
Click to hide internal directories.