Caching data with Redis
Redis is an extremely fast, open source, in-memory key value store. Redis has a useful Pub/Sub mechanism that we will use to push messages to a Socket.IO subscriber that will emit events to the client.
Visit this website in order to download and install Redis: http://redis.io/download.
Once Redis is installed, you can start it with the following command:
redis-server
In order to start the Redis command-line interface, CLI issues the following command:
redis-cli
The following commands can be issued from the CLI:
To monitor activity on Redis:
monitor
To clear the Redis store:
flushall
To view all the keys stored in Redis:
keys *
To get the value of a key:
get <key>
In order to use Redis in our application, install the node-redis
client, as follows:
npm install redis --save
Let's configure our application to use Redis by updating the./lib/config/*.json
config files with the following configuration:
"redis": { "port": 6379 , "host": "localhost" }
First, we...