mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-28 11:01:36 +08:00
Merge branch 'feat/raft'
# Conflicts: # cluster/cluster.go # cluster/router.go # config/config.go # database/database.go # database/server.go
This commit is contained in:
@@ -219,7 +219,7 @@ func (dict *ConcurrentDict) PutIfExistsWithLock(key string, val interface{}) (re
|
||||
}
|
||||
|
||||
// Remove removes the key and return the number of deleted key-value
|
||||
func (dict *ConcurrentDict) Remove(key string) (result int) {
|
||||
func (dict *ConcurrentDict) Remove(key string) (val interface{}, result int) {
|
||||
if dict == nil {
|
||||
panic("dict is nil")
|
||||
}
|
||||
@@ -229,15 +229,15 @@ func (dict *ConcurrentDict) Remove(key string) (result int) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if _, ok := s.m[key]; ok {
|
||||
if val, ok := s.m[key]; ok {
|
||||
delete(s.m, key)
|
||||
dict.decreaseCount()
|
||||
return 1
|
||||
return val, 1
|
||||
}
|
||||
return 0
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
func (dict *ConcurrentDict) RemoveWithLock(key string) (result int) {
|
||||
func (dict *ConcurrentDict) RemoveWithLock(key string) (val interface{}, result int) {
|
||||
if dict == nil {
|
||||
panic("dict is nil")
|
||||
}
|
||||
@@ -245,12 +245,12 @@ func (dict *ConcurrentDict) RemoveWithLock(key string) (result int) {
|
||||
index := dict.spread(hashCode)
|
||||
s := dict.getShard(index)
|
||||
|
||||
if _, ok := s.m[key]; ok {
|
||||
if val, ok := s.m[key]; ok {
|
||||
delete(s.m, key)
|
||||
dict.decreaseCount()
|
||||
return 1
|
||||
return val, 1
|
||||
}
|
||||
return 0
|
||||
return val, 0
|
||||
}
|
||||
|
||||
func (dict *ConcurrentDict) addCount() int32 {
|
||||
|
||||
Reference in New Issue
Block a user