cachedmap

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cachedmap provides a CachedMap which functions as a map with a TTL for old entries. So after an entry is "removed" from the map its value is still available for a certain amount of time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedMap

type CachedMap[Key comparable, T any] interface {
	Clear()
	Add(key Key, obj T)
	Remove(key Key)
	Keys() []Key
	Values() []T
	Get(key Key) (T, bool)
	GetCmp(cmp func(T) bool) (T, bool)
	// Close stops the background goroutine that prunes old entries
	Close()
}

func NewCachedMap

func NewCachedMap[Key comparable, T any](oldEntryTTL time.Duration) CachedMap[Key, T]

NewCachedMap creates a new CachedMap with the given oldEntryTTL The old entries will be deleted between oldEntryTTL and 2*oldEntryTTL

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL