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: 0

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