Documentation ¶
Index ¶
- type Cache
- func (c *Cache[K, V]) Delete(key K)
- func (c *Cache[K, V]) DeleteAll()
- func (c *Cache[K, V]) Load(key K) (value V, ok bool)
- func (c *Cache[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (c *Cache[K, V]) RangeAll() (values []V)
- func (c *Cache[K, V]) RangeCon(f func(key K, value V) bool) (values []V)
- func (c *Cache[K, V]) Store(key K, value V)
- func (c *Cache[K, V]) StoreAll(f func(value V) K, values []V)
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]) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present.
func (*Cache[K, V]) LoadOrStore ¶
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.
Click to show internal directories.
Click to hide internal directories.