forked from openhab/openhab-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis-helper.js
31 lines (24 loc) · 892 Bytes
/
redis-helper.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
// This module handles shared redis client for all
var app = require('./app.js'),
logger = require('./logger.js'),
redis = require('redis'),
redisClient;
logger.info('openHAB-cloud: Connecting ro Redis at ' + app.config.redis.host + ':' + app.config.redis.port);
redisClient = redis.createClient(app.config.redis.port, app.config.redis.host);
redisClient.auth(app.config.redis.password, function(error, data) {
if (error) {
logger.error(error);
} else {
logger.info('openHAB-cloud: Redis connect response: ' + data);
}
});
redisClient.on('ready', function () {
logger.info('Redis is ready');
});
redisClient.on('end', function () {
logger.error('openHAB-cloud: Redis error: connection is closed');
});
redisClient.on('error', function (error) {
logger.error('openHAB-cloud: Redis error: ' + error);
});
module.exports = redisClient;