-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis.js
36 lines (28 loc) · 784 Bytes
/
redis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const redis = require("redis");
const client = redis.createClient({
host: "localhost",
port: 6379
});
const { promisify } = require("util");
client.on("error", function(err) {
console.log(err);
});
const get = (exports.get = promisify(client.get.bind(client)));
const set = (exports.get = promisify(client.set.bind(client)));
const setex = (exports.get = promisify(client.setex.bind(client)));
const del = (exports.get = promisify(client.del.bind(client)));
set("funky", "chicken")
.then(function(val) {
console.log(val);
})
.catch(console.log);
// setex(
// "disco",
// 15,
// JSON.stringify({
// name: "disco duck",
// age: 58
// })
// ).then(function(val) {
// console.log(val);
// }).catch(console.log);