redis / hiredis

Minimalistic C client for Redis >= 1.2
BSD 3-Clause "New" or "Revised" License
6.15k stars 1.8k forks source link

KEYS ERROR IN VERSION 1.1.0 #1228

Closed dorebabu closed 9 months ago

dorebabu commented 9 months ago

Hello community,

In version 1.1.0, whereever I use keys E* along with redisCommand to find the tables of redis that start with E, I am not getting any result. Is this feature depricated in this version of hiredis.

Ex:

    reply = redisCommand (g_cfg_db.redis_db_ctxt, "KEYS PORT|E*");

This doesn't give the tables that start with PORT|E

Thank you .

sundb commented 9 months ago

Are you confusing glob-style pattern and regex? glob-style pattern doesn't support |.

dorebabu commented 9 months ago

Hii @sundb Thank you for being here. I used to use this kind of code as part of interacting with redis in version 0.15 of hiredis

reply = redisCommand (g_cfg_db.redis_db_ctxt, "KEYS PORT|E*");

But when I use the same thing now with 1.1.0 , it's not giving me any list of tables though they are present. 

So, this glob-style is it deprecated in 1.1.0 ?

And how can I use this now ?
sundb commented 9 months ago

@dorebabu I can't find version 0.15, so i used 0.14 to test and the result is still empty. AFAIK, The glob-style of the keys command has never had support for |.

michael-grunder commented 9 months ago

@sundb Is correct. Redis supports glob-style (e.g * and ? wildcard) pattern matching, but has never supported the regeg | OR operator, at least AFAIK.

You can verify this in redis-cli

127.0.0.1:6379> set "KEYS PORT" "some value"
OK
127.0.0.1:6379> set EGGS dozen
OK
127.0.0.1:6379> set ELEPHANTS "are big"
OK
127.0.0.1:6379> keys "KEYS PORT|E*"
(empty array)
127.0.0.1:6379> keys "KEYS PORT"
1) "KEYS PORT"
127.0.0.1:6379> keys "E*"
1) "ELEPHANTS"
2) "EGGS"
michael-grunder commented 9 months ago

Closing, since this isn't a bug in hiredis but happy to answer any other questions.