Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all keys of hashes in redis

Tags:

redis

Can somebody please give me something about how to get all categories and all users in this example

hmset category:1 name opera description music year 1573

OK

hmset category:2 name snowsports description sport Tmembers groups

OK

hmset category:3 name java description language year 1995

OK

hmset user:1 name jack age 23 country france

OK

hmset user:2 name john age 25 country Uk

Ok

hmset user:3 name julia age 27 country england

like image 914
user3401678 Avatar asked Nov 20 '25 09:11

user3401678


1 Answers

In that example, you'd have to do:

KEYS 'category:*'
KEYS 'user:*'

If you need to run this in production, use the SCAN command instead of keys. Assuming this is in db 0 on your Redis instance:

SCAN 0 match 'category:*'
SCAN 0 match 'user:*'
like image 162
Eli Avatar answered Nov 22 '25 05:11

Eli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!