Documentation ¶
Index ¶
- type IterCb
- type Map
- func (m Map) Clear()
- func (m Map) Count() int
- func (m Map) Del(key string)
- func (m Map) Get(key string) (interface{}, bool)
- func (m Map) GetShard(key string) *Shared
- func (m Map) GetString(key string) (string, bool)
- func (m Map) Has(key string) bool
- func (m Map) IsEmpty() bool
- func (m Map) Items() map[string]interface{}
- func (m Map) Iter() <-chan Tuple
- func (m Map) IterCb(fn IterCb)
- func (m Map) Keys() []string
- func (m Map) MSet(data map[string]interface{})
- func (m Map) MarshalJSON() ([]byte, error)
- func (m Map) Pop(key string) (v interface{}, exists bool)
- func (m Map) RemoveCb(key string, cb RemoveCb) bool
- func (m Map) Set(key string, value interface{})
- func (m Map) SetIfAbsent(key string, value interface{}) bool
- func (m Map) Upsert(key string, value interface{}, cb UpsertCb) (res interface{})
- type Option
- type OptionFn
- type RemoveCb
- type Shared
- type Tuple
- type UpsertCb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IterCb ¶
type IterCb func(key string, v interface{})
IterCb is 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 Map ¶
type Map struct { ShardCount int }
Map is a "thread" safe map of type string:Anything. To avoid lock bottlenecks this map is dived to several (ShardCount) map shards.
func (Map) MarshalJSON ¶
MarshalJSON reviles Map "private" variables to json marshal.
func (Map) RemoveCb ¶
RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)
func (Map) SetIfAbsent ¶
SetIfAbsent sets the given value under the specified key if no value was associated with it.
type RemoveCb ¶
RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map
type Shared ¶
type Shared struct { // contains filtered or unexported fields }
Shared is a "thread" safe string to anything map.
type Tuple ¶
type Tuple struct { Key string Val interface{} }
Tuple is 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{}
UpsertCb is 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