Redis / Get all keys and values ​​from redis with a prefix

I store my data in redis. I store in one raw this guid, createday and its size.

So, I define the following:

var dbclient1 = db.createClient(); dbclient1.hmset("doc:3743-da23-dcdf-3213", "date", "2015-09-06 00:00:01", "size", "203") dbclient1.zadd("cache", 32131, "37463-da23-dcdf-3213") 

I want to view all my files in my db. Therefore, I try:

 dbclient1.hgetall("doc:*", function (err, res){ console.log(err) console.log(res) }) 

but res is undefined . How can i do this?

+6
source share
1 answer

HGETALL returns all fields and hash values ​​stored in the key, you cannot specify a mask: http://redis.io/commands/hgetall p>

You can call KEYS doc:* to get a list of all the keys that match your criteria, and then get all the values ​​in the loop.

But please read the section on potential performance impact before you do this: http://redis.io/commands/keys

+8
source

Source: https://habr.com/ru/post/988776/


All Articles