timecache

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeCache

type TimeCache[K comparable] struct {
	// contains filtered or unexported fields
}

func New

func New[K comparable](size int, expiry time.Duration) *TimeCache[K]

New allocates a new Timecache with initial allocation size and expiry time. If `size` gets filled the timecache will allocate more memory to fit more elements into it. The cache will not shrink after regrowing. It is safe for concurrent use.

func (*TimeCache[K]) Add

func (tc *TimeCache[K]) Add(value *K)

Add adds a new key into the timecache, it doesn't guard against duplicated entries. Adding the same entry twice will result in undefined behaviour.

func (*TimeCache[K]) Get

func (tc *TimeCache[K]) Get(value *K) bool

Get returns true if the entry exists and it hasn't expired, false otherwise

Jump to

Keyboard shortcuts

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