cacheutil

package
v0.0.50-alpha.127 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 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

This section is empty.

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
}

Cache is a Generic sync.Map structure.

func NewCache

func NewCache[K comparable, V any]() *Cache[K, V]

func (*Cache[K, V]) Delete

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

Delete deletes the value for a key.

func (*Cache[K, V]) DeleteAll

func (c *Cache[K, V]) DeleteAll()

DeleteAll deletes all values.

func (*Cache[K, V]) Load

func (c *Cache[K, V]) Load(key K) (value V, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present.

func (*Cache[K, V]) LoadOrStore

func (c *Cache[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)

LoadOrStore returns the existing value for the key if present.

func (*Cache[K, V]) RangeAll

func (c *Cache[K, V]) RangeAll() (values []V)

RangeAll returns all values in the map.

func (*Cache[K, V]) RangeCon

func (c *Cache[K, V]) RangeCon(f func(key K, value V) bool) (values []V)

RangeCon returns values in the map that satisfy condition f.

func (*Cache[K, V]) Store

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

Store sets the value for a key.

func (*Cache[K, V]) StoreAll

func (c *Cache[K, V]) StoreAll(f func(value V) K, values []V)

StoreAll sets all value by f's key.

Jump to

Keyboard shortcuts

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