genericcache

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ErrorExpired = Error("key exists but it's expired")
View Source
const ErrorKey = Error("key does not exist in cache")
View Source
const NoExpiration = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K hashable, V any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[K hashable, V any](lifetime time.Duration) *Cache[K, V]

func (*Cache[K, V]) Del

func (c *Cache[K, V]) Del(key K)

func (*Cache[K, V]) ForEach

func (c *Cache[K, V]) ForEach(f func(K, wrapper[V]) bool)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(key K) (value V, err error)

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, value V)

func (*Cache[K, V]) Swap

func (c *Cache[K, V]) Swap(key K, newValue V) (oldValue V, swapped bool)

type Error

type Error string

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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