Storing and retrieving data with Redis
Redis is a key value store that in operational with blazingly performance.
Redis is excellent for certain tasks, as long as data model is simple.
Good examples of where Redis shines are in site analytics, server-side session cookies, and providing a list of logged-in users in real time.
In the spirit of this chapter's theme, let's reimplement our quotes database with Redis.
Getting ready
Let's create a new folder called redis-app
with an index.js
file, initialize it, and install redis
, steed
, and uuid
:
$ mkdir redis-app $ cd redis-app $ touch index.js $ npm init -y $ npm install --save redis steed uuid
We also need to install the server, which can be downloaded from http://www.redis.io/download along with the installation instructions.
How to do it...
Let's load the supporting dependencies, along with the redis
module, establish a connection, and listen for the ready event emitted by the client.
We'll also load the command-line arguments into the params...