Documentation ¶
Overview ¶
A thread safe map implementation for Golang
Index ¶
- type Item
- type IterItemFunc
- type IterItemWithBreakFunc
- type IterKeyFunc
- type IterKeyWithBreakFunc
- type SyncMap
- func (m *SyncMap) Delete(key string)
- func (m *SyncMap) EachItem(iter IterItemFunc)
- func (m *SyncMap) EachItemWithBreak(iter IterItemWithBreakFunc)
- func (m *SyncMap) EachKey(iter IterKeyFunc)
- func (m *SyncMap) EachKeyWithBreak(iter IterKeyWithBreakFunc)
- func (m *SyncMap) Flush() int
- func (m *SyncMap) Get(key string) (value interface{}, ok bool)
- func (m *SyncMap) Has(key string) bool
- func (m *SyncMap) IterItems() <-chan Item
- func (m *SyncMap) IterKeys() <-chan string
- func (m *SyncMap) Pop() (string, interface{})
- func (m *SyncMap) Set(key string, value interface{})
- func (m *SyncMap) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IterItemFunc ¶
type IterItemFunc func(item *Item)
IterItemFunc is the type of the function called for every item.
Don't modify the SyncMap in this function, or maybe leads to deadlock.
type IterItemWithBreakFunc ¶
IterItemWithBreakFunc is the type of the function called for each item.
If false is returned,each item stops. Don't modify the SyncMap in this function, or maybe leads to deadlock.
type IterKeyFunc ¶
type IterKeyFunc func(key string)
IterKeyFunc is the type of the function called for every key.
Don't modify the SyncMap in this function, or maybe leads to deadlock.
type IterKeyWithBreakFunc ¶
IterKeyWithBreakFunc is the type of the function called for each key.
If false is returned,each key stops. Don't modify the SyncMap in this function, or maybe leads to deadlock.
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
SyncMap keeps a slice of *syncMap with length of `shardCount`. Using a slice of syncMap instead of a large one is to avoid lock bottlenecks.
func NewWithShard ¶
Create a new SyncMap with given shard count. NOTE: shard count must be power of 2, default shard count will be used otherwise.
func (*SyncMap) EachItem ¶
func (m *SyncMap) EachItem(iter IterItemFunc)
func (*SyncMap) EachItemWithBreak ¶
func (m *SyncMap) EachItemWithBreak(iter IterItemWithBreakFunc)
func (*SyncMap) EachKey ¶
func (m *SyncMap) EachKey(iter IterKeyFunc)
func (*SyncMap) EachKeyWithBreak ¶
func (m *SyncMap) EachKeyWithBreak(iter IterKeyWithBreakFunc)
func (*SyncMap) IterItems ¶
Return a channel from which each item (key:value pair) in the map can be read