Redis is a great database for use with Node.js. Both Redis Node.js share similar type conventions and threading models, which makes for a very predictable development experience. By pairing Node.js & Redis together you can achieve a scalable and productive development platform.
Redis Node.js has two primary clients available node_redis and ioredis. Both are available through npm. Both clients have pros and cons, but we generally suggest node_redis, as it has wide support for Redis modules, it is easily extensible and widely used. Ioredis has better integrated support for the Redis Enterprise Cluster API, but this is only relevant if your specifically using the Cluster API topology instead of the more common Proxy topology. Node_redis’ support for the Cluster API is provided by an additional shim, redis-clustr. Node_redis has built-in support for Redis Enterprise features such as Active Active geo distribution, allowing you to have one database that spans multiple clusters. Node_redis also supports Redis-on-Flash which enables extending your database into Flash SSD storage for warm values and DRAM for hot values. Nodejs redis enables you to integrate such features.
With REdis nodejs, Node_redis has good support for using Redis modules, however, being an interpreted language, it does not support building modules with the Redis Modules SDK. The client can be extended with the redis.add_command function prior to creating a client. Bindings exist for most common modules including:
Connecting to Redis Node.js
For Redis nodejs download, Install the package with npm
npm install redis
After installing the node Redis package into your project, you’ll need to require the Node.js module as well as create an instance with your configuration details:
With REdis nodejs, Node_redis manages connections automatically, so there is no need to wait for connection or callback. Since Node.js and Redis are both effectively single threaded there is no need to use multiple client instances or any pooling mechanism save for a few exceptions; the most common exception is if you’re subscribing with Pub/Sub or blocking with streams or lists, then you’ll need to have dedicated clients to receive these long-running commands.
To manipulate data in node_redis, each node Redis command is implemented as a method of the client object. All Redis commands are included.
Try Redis Nodejs with Redis Enterprise
Further Reading Related to Node.js and Redis
- IoT Backend with Redis, S3 and Node.js
- Redis HyperLogLog: A Deep Dive
- RediSearch got a lot more interesting
- Mastering RediSearch / Part 1
- Mastering RediSearch / Part 2
- Mastering RediSearch / Part 3
For more information on using Redis Labs’ products and services with Node.js please see the Howto page.