Documentation ¶
Overview ¶
Package store provides Store, which is an alternative to the sync.Map type and supports both type-safety using 1.18 generics and avoids the unsafe package.
Index ¶
- type Store
- func (s *Store[T, K]) Delete(key T) (ok bool)
- func (s *Store[T, K]) ForEach(f func(key T, value K))
- func (s *Store[T, K]) Get(key T) (value K, ok bool)
- func (s *Store[T, K]) GetOrSet(key T, val K) (value K, set bool)
- func (s *Store[T, K]) Pluck(key T) (value K, ok bool)
- func (s *Store[T, K]) Reset()
- func (s *Store[T, K]) Set(key T, val K)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store[T comparable, K any] struct { // contains filtered or unexported fields }
Store is a go-routine safe way to store an arbitrary map. Its zero-value is safe to use. It must not be copied after first use.
func (*Store[T, K]) ForEach ¶
func (s *Store[T, K]) ForEach(f func(key T, value K))
ForEach calls the provided function for each value stored.
func (*Store[T, K]) GetOrSet ¶
GetOrSet only stores value under key if no value already exists under key, returns true if successful.
Click to show internal directories.
Click to hide internal directories.