Basic question: Using Node.js I would like to get all the keys in my redis db. My redis db looks like this when I call keys *;
- aXF
- x9U
- lOk
So each record I have, has a unique key, generated as a random string. Now I would like to call something like foreach(key in Redis) and get all keys in the redis. Would it be possible to accomplish a “SELECT * FROM Redis”-like query with Node.js & Redis
Sure, you’ll need to install the
redismodule fornodejswhich can be found at https://github.com/redis/node-redis.Then you would do:
Generally speaking you won’t want to always return all of the keys (performance will be bad for larger data sets), but this will work if you are just testing things out. There is even a nice warning in the
Redisdocumentation: