mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
addCount should only be executed when there is data insertion
This commit is contained in:
@@ -109,7 +109,6 @@ func (dict *ConcurrentDict) Put(key string, val interface{}) (result int) {
|
|||||||
hashCode := fnv32(key)
|
hashCode := fnv32(key)
|
||||||
index := dict.spread(hashCode)
|
index := dict.spread(hashCode)
|
||||||
s := dict.getShard(index)
|
s := dict.getShard(index)
|
||||||
dict.addCount()
|
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
|
|
||||||
@@ -117,6 +116,7 @@ func (dict *ConcurrentDict) Put(key string, val interface{}) (result int) {
|
|||||||
s.m[key] = val
|
s.m[key] = val
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
dict.addCount()
|
||||||
s.m[key] = val
|
s.m[key] = val
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user