Install Client Library for Node
Install and Start Redis via brew
brew services start redis
Install and Start Redis on Windows
https://github.com/MicrosoftArchive/redis/releases
redis-server.exe
Ping Server
Connection String
const redisUrl = 'redis//127.0.0.1:6379';
Create Client
const client = redis.createClient(redisUrl);
Storing/Setting A Key-Value Pair
client.set('greeting', 'hello') // Returns true or false {'greeting': 'hello'}
Getting A Key-Value Pair
// Returns true or false
client.get('greeting', (err,value) => {
console.log(value); // Will log 'hello'
}
Easy way to log
client.get('greeting', console.log);