-
Notifications
You must be signed in to change notification settings - Fork 0
/
redisService.js
39 lines (35 loc) · 964 Bytes
/
redisService.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
37
38
39
/*
* @Author: Dat Dev
* @Date: 2016-04-23 14:38:07
* @Last Modified by: Stefan Wirth
* @Last Modified time: 2016-04-23 15:34:18
*/
'use strict';
var config = require('./config');
var client = require('redis').createClient({url: config.redis.url});
var Promise = require('bluebird');
client.on('err', function(err) {
console.error(err);
});
module.exports = {
set: function(key, value) {
return new Promise(function(resolve, reject) {
client.set(key, value, function(err, reply) {
if(err) {
return reject(err);
}
return resolve(reply);
});
});
},
get: function(key) {
return new Promise(function(resolve, reject) {
client.get(key, function(err, reply) {
if(err) {
return reject(err);
}
return resolve(reply);
});
});
}
}