cache

package
v3.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

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 added in v3.4.0

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

Delete deletes the value for a key.

func (*Cache[K, V]) DeleteAll added in v3.4.0

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

DeleteAll deletes all values.

func (*Cache[K, V]) Load added in v3.4.0

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 added in v3.4.0

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 added in v3.4.0

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

RangeAll returns all values in the map.

func (*Cache[K, V]) RangeCon added in v3.4.0

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 added in v3.4.0

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

Store sets the value for a key.

func (*Cache[K, V]) StoreAll added in v3.4.0

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