Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SyncMap ¶
type SyncMap[K comparable, V any] struct { sync.Map }
SyncMap wraps a sync.Map with type parameters such that it's easier to access the items stored in the map since no type assertion is needed. It also requires explicit type definition when declaring and initiating the variables, which helps us understanding what's stored in a given map.
func (*SyncMap[K, V]) Delete ¶
func (m *SyncMap[K, V]) Delete(key K)
Delete removes an item from the map specified by the key.
func (*SyncMap[K, V]) Load ¶
Load queries an item from the map using the specified key. If the item cannot be found, an empty value and false will be returned. If the stored item fails the type assertion, a nil value and false will be returned.
func (*SyncMap[K, V]) LoadAndDelete ¶
LoadAndDelete queries an item and deletes it from the map using the specified key.
Click to show internal directories.
Click to hide internal directories.