feat: add full search for hash

This commit is contained in:
Lykin
2023-11-20 18:38:23 +08:00
parent db4e2385fc
commit eca640fc87
4 changed files with 31 additions and 70 deletions

View File

@@ -692,6 +692,12 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
}
case "hash":
if !strings.HasPrefix(matchPattern, "*") {
matchPattern = "*" + matchPattern
}
if !strings.HasSuffix(matchPattern, "*") {
matchPattern = matchPattern + "*"
}
loadHashHandle := func() ([]types.HashEntryItem, bool, bool, error) {
var items []types.HashEntryItem
var loadedVal []string
@@ -699,11 +705,11 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS
var reset bool
var subErr error
scanSize := int64(Preferences().GetScanSize())
if param.Full {
if param.Full || matchPattern != "*" {
// load all
cursor, reset = 0, true
for {
loadedVal, cursor, subErr = client.HScan(ctx, key, cursor, "*", scanSize).Result()
loadedVal, cursor, subErr = client.HScan(ctx, key, cursor, matchPattern, scanSize).Result()
if subErr != nil {
return nil, reset, false, subErr
}