use regex implementing wildcard

This commit is contained in:
finley
2022-07-08 23:48:42 +08:00
parent 9e155a617c
commit 98f986a363
3 changed files with 104 additions and 121 deletions

View File

@@ -280,7 +280,10 @@ func execPersist(db *DB, args [][]byte) redis.Reply {
// execKeys returns all keys matching the given pattern
func execKeys(db *DB, args [][]byte) redis.Reply {
pattern := wildcard.CompilePattern(string(args[0]))
pattern, err := wildcard.CompilePattern(string(args[0]))
if err != nil {
return protocol.MakeErrReply("ERR illegal wildcard")
}
result := make([][]byte, 0)
db.data.ForEach(func(key string, val interface{}) bool {
if pattern.IsMatch(key) {