Documentation ¶
Index ¶
- func Keys[K comparable, V any](ms ...map[K]V) []K
- func PopEncode(str string) string
- func Values[K comparable, V any](ms ...map[K]V) []V
- type Body
- type KV
- func (m KV[K, V]) Delete(keys ...K)
- func (m KV[K, V]) Get(key K) (V, bool)
- func (m KV[K, V]) Has(key K) bool
- func (m KV[K, V]) Keys() []K
- func (m KV[K, V]) Len() int
- func (m KV[K, V]) Range(fn func(key K, value V) bool)
- func (m KV[K, V]) Set(key K, value V)
- func (m KV[K, V]) SetNx(key K, value V) bool
- func (m KV[K, V]) SetX(key K, value V) bool
- func (m KV[K, V]) Values() []V
- type SafeKV
- func (s *SafeKV[K, V]) All() iter.Seq2[K, V]
- func (s *SafeKV[K, V]) Clear()
- func (s *SafeKV[K, V]) Delete(keys ...K)
- func (s *SafeKV[K, V]) Get(key K) (V, bool)
- func (s *SafeKV[K, V]) GetWithLock(key K, fn func(V))
- func (s *SafeKV[K, V]) GetWithMap(m map[K]V)
- func (s *SafeKV[K, V]) Has(key K) bool
- func (s *SafeKV[K, V]) Keys() []K
- func (s *SafeKV[K, V]) Len() int
- func (s *SafeKV[K, V]) Map(fn func(KV[K, V]))
- func (s *SafeKV[K, V]) Range(fn func(key K, value V) bool)
- func (s *SafeKV[K, V]) Set(key K, value V)
- func (s *SafeKV[K, V]) SetNx(key K, value V) bool
- func (s *SafeKV[K, V]) SetX(key K, value V) bool
- func (s *SafeKV[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Keys ¶ added in v0.0.13
func Keys[K comparable, V any](ms ...map[K]V) []K
Keys returns all keys of the map.
func Values ¶ added in v0.0.13
func Values[K comparable, V any](ms ...map[K]V) []V
Values returns all values of the map.
Types ¶
type Body ¶
Body is a map[string]any
func (Body) All ¶ added in v0.0.17
All returns an iterator that yields all key-value pairs in the Body.
func (Body) QueryBytes ¶
QueryBytes returns the query bytes
func (Body) QueryString ¶
QueryString returns the query string
type KV ¶ added in v0.0.15
type KV[K comparable, V any] map[K]V
func (KV[K, V]) Delete ¶ added in v0.0.15
func (m KV[K, V]) Delete(keys ...K)
Delete deletes the value associated with the key.
func (KV[K, V]) Get ¶ added in v0.0.15
Get returns the value associated with the key and whether the key existed or not.
func (KV[K, V]) Range ¶ added in v0.0.15
Range calls fn sequentially for each key and value present in the map.
func (KV[K, V]) Set ¶ added in v0.0.15
func (m KV[K, V]) Set(key K, value V)
Set sets the value associated with the key.
func (KV[K, V]) SetNx ¶ added in v0.0.15
SetNx sets the value associated with the key if the key does not exist.
type SafeKV ¶
type SafeKV[K comparable, V any] struct { // contains filtered or unexported fields }
SafeKV is a thread-safe map
func NewSafeKV ¶
func NewSafeKV[K comparable, V any](cap int) *SafeKV[K, V]
NewSafeKV creates a new SafeKV
func (*SafeKV[K, V]) All ¶ added in v0.0.17
All returns an iterator that yields all key-value pairs in the SafeKV.
func (*SafeKV[K, V]) Delete ¶
func (s *SafeKV[K, V]) Delete(keys ...K)
Delete deletes the value associated with the key
func (*SafeKV[K, V]) Get ¶
Get returns the value associated with the key and whether the key existed
func (*SafeKV[K, V]) GetWithLock ¶ added in v0.0.15
func (s *SafeKV[K, V]) GetWithLock(key K, fn func(V))
GetWithLock calls fn with the value associated with the key if the key existed
func (*SafeKV[K, V]) GetWithMap ¶ added in v0.0.15
func (s *SafeKV[K, V]) GetWithMap(m map[K]V)
GetWithMap returns the value associated with the key and whether the key existed
func (*SafeKV[K, V]) Keys ¶ added in v0.0.15
func (s *SafeKV[K, V]) Keys() []K
Keys returns all the keys
func (*SafeKV[K, V]) Set ¶
func (s *SafeKV[K, V]) Set(key K, value V)
Set sets the value associated with the key