Created
July 28, 2020 08:01
-
-
Save redrush85/55728e0c8860d2f10a9721e961363d98 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func (svc Service) clearCacheByMask(ctx context.Context, mask string) error { | |
var ( | |
iter uint64 | |
keys []string | |
) | |
for { | |
if arr, cursor, err := svc.redisCli.Scan(iter, mask, 100).Result(); err != nil { | |
return err | |
} else { | |
keys = append(keys, arr...) | |
iter = cursor | |
} | |
if iter == 0 { | |
break | |
} | |
} | |
if len(keys) > 0 { | |
_, err := svc.redisCli.Del(keys...).Result() | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment