mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-21 15:59:26 +08:00
ConcurrentDict Remove add decreaseCount
This commit is contained in:
@@ -168,6 +168,7 @@ func (dict *ConcurrentDict) Remove(key string) (result int) {
|
||||
|
||||
if _, ok := shard.m[key]; ok {
|
||||
delete(shard.m, key)
|
||||
dict.decreaseCount()
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
@@ -177,6 +178,10 @@ func (dict *ConcurrentDict) addCount() int32 {
|
||||
return atomic.AddInt32(&dict.count, 1)
|
||||
}
|
||||
|
||||
func (dict *ConcurrentDict) decreaseCount() int32 {
|
||||
return atomic.AddInt32(&dict.count, -1)
|
||||
}
|
||||
|
||||
// ForEach traversal the dict
|
||||
// it may not visits new entry inserted during traversal
|
||||
func (dict *ConcurrentDict) ForEach(consumer Consumer) {
|
||||
|
Reference in New Issue
Block a user