Documentation ¶
Index ¶
- type ConcurrentHashMap
- func (m *ConcurrentHashMap) AddIfPresent(key int16, value interface{}) bool
- func (m *ConcurrentHashMap) AddIfPresentWithFun(key int16, newVal interface{}, fn fun)
- func (m *ConcurrentHashMap) Count() int
- func (m *ConcurrentHashMap) Erase()
- func (m *ConcurrentHashMap) Get(key int16) (interface{}, bool)
- func (m *ConcurrentHashMap) GetShard(key int16) *ConcurrentMapShared
- func (m *ConcurrentHashMap) Has(key int16) bool
- func (m *ConcurrentHashMap) IsEmpty() bool
- func (m *ConcurrentHashMap) Items() map[int16]interface{}
- func (m *ConcurrentHashMap) Iter() <-chan Tupledeprecated
- func (m *ConcurrentHashMap) IterBuffered() <-chan Tuple
- func (m *ConcurrentHashMap) IterCb(fn IterCb)
- func (m *ConcurrentHashMap) Keys() []int16
- func (m *ConcurrentHashMap) MSet(data map[int16]interface{})
- func (m *ConcurrentHashMap) MarshalJSON() ([]byte, error)
- func (m *ConcurrentHashMap) Pop(key int16) (v interface{}, exists bool)
- func (m *ConcurrentHashMap) Remove(key int16)
- func (m *ConcurrentHashMap) Set(key int16, value interface{})
- func (m *ConcurrentHashMap) SetIfAbsent(key int16, value interface{}) bool
- func (m *ConcurrentHashMap) SetIfPresent(key int16, newValue, oldValue interface{}) bool
- func (m *ConcurrentHashMap) Upsert(key int16, value interface{}, cb UpsertCb) (res interface{})
- type ConcurrentMap
- type ConcurrentMapShared
- type IterCb
- type Tuple
- type UpsertCb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentHashMap ¶
type ConcurrentHashMap struct { Shards int HashMap ConcurrentMap }
func (*ConcurrentHashMap) AddIfPresent ¶
func (m *ConcurrentHashMap) AddIfPresent(key int16, value interface{}) bool
Sets the given value under the specified key if oldValue was associated with it.
func (*ConcurrentHashMap) AddIfPresentWithFun ¶ added in v1.0.1
func (m *ConcurrentHashMap) AddIfPresentWithFun(key int16, newVal interface{}, fn fun)
func (*ConcurrentHashMap) Count ¶
func (m *ConcurrentHashMap) Count() int
Returns the number of elements within the map.
func (*ConcurrentHashMap) Erase ¶ added in v1.0.1
func (m *ConcurrentHashMap) Erase()
Removes an element from the map.
func (*ConcurrentHashMap) Get ¶
func (m *ConcurrentHashMap) Get(key int16) (interface{}, bool)
Retrieves an element from map under given key.
func (*ConcurrentHashMap) GetShard ¶
func (m *ConcurrentHashMap) GetShard(key int16) *ConcurrentMapShared
Returns shard under given key
func (*ConcurrentHashMap) Has ¶
func (m *ConcurrentHashMap) Has(key int16) bool
Looks up an item under specified key
func (*ConcurrentHashMap) IsEmpty ¶
func (m *ConcurrentHashMap) IsEmpty() bool
Checks if map is empty.
func (*ConcurrentHashMap) Items ¶
func (m *ConcurrentHashMap) Items() map[int16]interface{}
Returns all items as map[int16]interface{}
func (*ConcurrentHashMap) Iter
deprecated
func (m *ConcurrentHashMap) Iter() <-chan Tuple
Returns an iterator which could be used in a for range loop.
Deprecated: using IterBuffered() will get a better performence
func (*ConcurrentHashMap) IterBuffered ¶
func (m *ConcurrentHashMap) IterBuffered() <-chan Tuple
Returns a buffered iterator which could be used in a for range loop.
func (*ConcurrentHashMap) IterCb ¶
func (m *ConcurrentHashMap) IterCb(fn IterCb)
Callback based iterator, cheapest way to read all elements in a map.
func (*ConcurrentHashMap) Keys ¶
func (m *ConcurrentHashMap) Keys() []int16
Return all keys as []int16
func (*ConcurrentHashMap) MSet ¶
func (m *ConcurrentHashMap) MSet(data map[int16]interface{})
Sets the given map
func (*ConcurrentHashMap) MarshalJSON ¶
func (m *ConcurrentHashMap) MarshalJSON() ([]byte, error)
Reviles ConcurrentHashMap "private" variables to json marshal.
func (*ConcurrentHashMap) Pop ¶
func (m *ConcurrentHashMap) Pop(key int16) (v interface{}, exists bool)
Removes an element from the map and returns it
func (*ConcurrentHashMap) Remove ¶
func (m *ConcurrentHashMap) Remove(key int16)
Removes an element from the map.
func (*ConcurrentHashMap) Set ¶
func (m *ConcurrentHashMap) Set(key int16, value interface{})
Sets the given value under the specified key.
func (*ConcurrentHashMap) SetIfAbsent ¶
func (m *ConcurrentHashMap) SetIfAbsent(key int16, value interface{}) bool
Sets the given value under the specified key if no value was associated with it.
func (*ConcurrentHashMap) SetIfPresent ¶
func (m *ConcurrentHashMap) SetIfPresent(key int16, newValue, oldValue interface{}) bool
Sets the given value under the specified key if oldValue was associated with it.
func (*ConcurrentHashMap) Upsert ¶
func (m *ConcurrentHashMap) Upsert(key int16, value interface{}, cb UpsertCb) (res interface{})
Insert or Update - updates existing element or inserts a new one using UpsertCb
type ConcurrentMap ¶
type ConcurrentMap []*ConcurrentMapShared
A "thread" safe map of type int16:Anything. To avoid lock bottlenecks this map is dived to several (Shards) map shards.
type ConcurrentMapShared ¶
type ConcurrentMapShared struct { // contains filtered or unexported fields }
A "thread" safe int16 to anything map.
type IterCb ¶
type IterCb func(key int16, v interface{})
Iterator callback,called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sess consistent view of a shard, but not across the shards
type Tuple ¶
type Tuple struct { Key int16 Val interface{} }
Used by the Iter & IterBuffered functions to wrap two variables together over a channel,
type UpsertCb ¶
type UpsertCb func(exist bool, valueInMap interface{}, newValue interface{}) interface{}
Callback to return new element to be inserted into the map It is called while lock is held, therefore it MUST NOT try to access other keys in same map, as it can lead to deadlock since Go sync.RWLock is not reentrant