kocgo / Redis_Notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install Client Library for Node

npm install redis

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

redis-cli ping

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);

About