cache

package
v1.20.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	GET requestType = iota
	SET
	DELETE
	EXPIRE
	COPY
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func MakeCache

func MakeCache[K comparable, V any](ctimeExpiry, atimeExpiry time.Duration) *Cache[K, V]

func (*Cache[K, V]) Copy

func (c *Cache[K, V]) Copy() map[K]V

func (*Cache[K, V]) Delete

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

func (*Cache[K, V]) Get

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

func (*Cache[K, V]) IsOld

func (c *Cache[K, V]) IsOld(v *Value[V]) bool

func (*Cache[K, V]) Set

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

if key exists in the cache, the new value is NOT set; instead an error and the old value are returned

type Value

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

Jump to

Keyboard shortcuts

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