cache

package
v0.1.87 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeoutCache

type TimeoutCache[V any] struct {
	// contains filtered or unexported fields
}

TimeoutCache provides a cache with timeout.

func New

func New[V any](refresh time.Duration) *TimeoutCache[V]

New gets a new cache.

func (*TimeoutCache[V]) Get

func (m *TimeoutCache[V]) Get() (value V, ok bool)

Get returns the cached value if set and it hasn't timed out and returns true. If it has timed out, it will return V's zero value and false, and will need to be set again.

func (*TimeoutCache[V]) Set

func (m *TimeoutCache[V]) Set(value V)

Set remembers the value and resets the invalid time based on when the cache was set.

Jump to

Keyboard shortcuts

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