I want to use HSCAN match clause to match a key which is of type 1 or type 2. A regex would be like ^match1|^match2
. Is it possible to do this in glob style pattern.
I want to use HSCAN match clause to match a key which is of type 1 or type 2. A regex would be like ^match1|^match2
. Is it possible to do this in glob style pattern.
2
Answers
Redis does not offer a straight forward way to match multiple patterns.
Redis matchs using glob-style pattern which is very limited.
Supported glob-style patterns:
Use to escape special characters if you want to match them verbatim.
You can’t use glob-style for that, but you can Lua your way around this. That means you can use
EVAL
and a script (can be similar to https://github.com/itamarhaber/redis-lua-scripts/blob/master/scanregex.lua) for performing theHSCAN match1*
first, and then filtering with Lua onmatch2.*
.