Documentation
¶
Index ¶
- type DelFunc
- type LockMap
- func (m *LockMap[K, V]) Del(key K)
- func (m *LockMap[K, V]) Get(key K) (value V, exist bool)
- func (m *LockMap[K, V]) GetSet(key K, value V) (oldValue V, exist bool)
- func (m *LockMap[K, V]) Len() (n int)
- func (m *LockMap[K, V]) SafeRange(f func(key K, value V) bool)
- func (m *LockMap[K, V]) Set(key K, value V)
- func (m *LockMap[K, V]) SetNX(key K, value V)
- func (m *LockMap[K, V]) UnsafeDel(key K)
- func (m *LockMap[K, V]) UnsafeGet(key K) (value V, exist bool)
- func (m *LockMap[K, V]) UnsafeGetSet(key K, value V) (oldValue V, exist bool)
- func (m *LockMap[K, V]) UnsafeLen() int
- func (m *LockMap[K, V]) UnsafeRange(f func(key K, value V) bool)
- func (m *LockMap[K, V]) UnsafeSet(key K, value V)
- func (m *LockMap[K, V]) UnsafeSetNX(key K, value V)
- type Map
- func (m *Map[K, V]) Del(key K)
- func (m *Map[K, V]) Get(key K) (value V, exist bool)
- func (m *Map[K, V]) GetSet(key K, value V) (oldValue V, exist bool)
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Range(f func(key K, value V) bool)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetNX(key K, value V)
- type RangeFunc
- type ShardMap
- func (m *ShardMap[K, V]) Clean()
- func (m *ShardMap[K, V]) Del(key K)
- func (m *ShardMap[K, V]) DelWithFunc(key K, fn DelFunc[K, V]) bool
- func (m *ShardMap[K, V]) Exists(key K) bool
- func (m *ShardMap[K, V]) Get(key K) (V, bool)
- func (m *ShardMap[K, V]) GetShard(key K) *ShardUnit[K, V]
- func (m *ShardMap[K, V]) IterBuffered() <-chan Tuple[K, V]
- func (m *ShardMap[K, V]) Keys() []K
- func (m *ShardMap[K, V]) Len() int
- func (m *ShardMap[K, V]) MSet(data map[K]V)
- func (m *ShardMap[K, V]) MarshalJSON() ([]byte, error)
- func (m *ShardMap[K, V]) Pop(key K) (v V, exists bool)
- func (m *ShardMap[K, V]) Range(f RangeFunc[K, V])
- func (m *ShardMap[K, V]) Set(key K, value V)
- func (m *ShardMap[K, V]) SetNX(key K, value V) bool
- func (m *ShardMap[K, V]) UnmarshalJSON(b []byte) (err error)
- func (m *ShardMap[K, V]) Upsert(key K, value V, fn UpsertFunc[V]) (res V)
- type ShardUnit
- type Stringer
- type Tuple
- type UpsertFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LockMap ¶
type LockMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewLockMap ¶
func NewLockMap[K comparable, V any]() *LockMap[K, V]
func (*LockMap[K, V]) UnsafeGetSet ¶
func (*LockMap[K, V]) UnsafeRange ¶
func (*LockMap[K, V]) UnsafeSetNX ¶
func (m *LockMap[K, V]) UnsafeSetNX(key K, value V)
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
func NewMap ¶
func NewMap[K comparable, V any]() *Map[K, V]
type RangeFunc ¶
type RangeFunc[K comparable, V any] func(key K, value V) bool
RangeFunc map迭代器,返回false则终止遍历
type ShardMap ¶
type ShardMap[K comparable, V any] struct { // contains filtered or unexported fields }
ShardMap 线程安全的map[comparable, any],为了避免锁带来的性能瓶颈,将map进行了分片
func NewShardMapWithStringer ¶
func (*ShardMap[K, V]) DelWithFunc ¶
func (*ShardMap[K, V]) IterBuffered ¶
IterBuffered returns a buffered iterator which could be used in a for range loop.
func (*ShardMap[K, V]) MarshalJSON ¶
MarshalJSON JSON序列化
func (*ShardMap[K, V]) UnmarshalJSON ¶
UnmarshalJSON JSON反序列化 先反序列化进一个map中,然后一次set进ShardMap
func (*ShardMap[K, V]) Upsert ¶
func (m *ShardMap[K, V]) Upsert(key K, value V, fn UpsertFunc[V]) (res V)
Upsert 通过UpdateCb更新既有的key或者新插入key
type ShardUnit ¶
type ShardUnit[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields }
ShardUnit 线程安全的map[string]any
type Stringer ¶
type Stringer interface { fmt.Stringer comparable }
type Tuple ¶
type Tuple[K comparable, V any] struct { Key K Val V }
Tuple Used by the Iter & IterBuffered functions to wrap two variables together over a channel,
type UpsertFunc ¶
UpsertFunc 更新或者插入新key的func exist: 表示需要更新或者插入的key是否存在 oldValue: 如果key存在,表示其既有的值 updateValue: 需要更新(或插入)的新值
Click to show internal directories.
Click to hide internal directories.