-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed some critical issues in the k/v logic
- Loading branch information
1 parent
ce94325
commit 8ac1e07
Showing
3 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package local | ||
|
||
func (api *API) addToKeyIndex(key string) error { | ||
o, err := api.Store.Get(keyIndexKey) | ||
if err != nil { | ||
// not found, create new | ||
o = &Object{ | ||
Type: TypeSet, | ||
Value: map[string]interface{}{key: true}, | ||
NoExp: true, | ||
} | ||
|
||
return api.Store.Set(keyIndexKey, o) | ||
} | ||
|
||
if o == nil { | ||
o = &Object{ | ||
Type: TypeSet, | ||
Value: map[string]interface{}{key: true}, | ||
NoExp: true, | ||
} | ||
} | ||
|
||
list := o.Value.(map[string]interface{}) | ||
list[key] = true | ||
|
||
o.Value = list | ||
|
||
err = api.Store.Set(keyIndexKey, o) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (api *API) updateDeletedKeysIndex(key string) error { | ||
o, err := api.Store.Get(deletedKeyIndexKey) | ||
if err != nil { | ||
// not found, create new | ||
o = &Object{ | ||
Type: TypeSet, | ||
Value: map[string]interface{}{key: true}, | ||
NoExp: true, | ||
} | ||
|
||
return api.Store.Set(deletedKeyIndexKey, o) | ||
} | ||
|
||
if o == nil { | ||
o = &Object{ | ||
Type: TypeSet, | ||
Value: map[string]interface{}{key: true}, | ||
NoExp: true, | ||
} | ||
} | ||
|
||
list := o.Value.(map[string]interface{}) | ||
list[key] = true | ||
o.Value = list | ||
|
||
return api.Store.Set(deletedKeyIndexKey, o) | ||
} |