MCPcopy Index your code
hub / github.com/aceld/zinx / SetNX

Method SetNX

zutils/shard_lock_map.go:110–119  ·  view source on GitHub ↗

SetNX Sets the given value under the specified key if no value was associated with it.

(key string, value interface{})

Source from the content-addressed store, hash-verified

108
109// SetNX Sets the given value under the specified key if no value was associated with it.
110func (slm ShardLockMaps) SetNX(key string, value interface{}) bool {
111 shard := slm.GetShard(key)
112 shard.Lock()
113 _, ok := shard.items[key]
114 if !ok {
115 shard.items[key] = value
116 }
117 shard.Unlock()
118 return !ok
119}
120
121// MSet Sets the given value under the specified key.
122func (slm ShardLockMaps) MSet(data map[string]interface{}) {

Callers 1

TestSetFunction · 0.95

Calls 1

GetShardMethod · 0.95

Tested by 1

TestSetFunction · 0.76