You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
683 B
26 lines
683 B
'use strict';
|
|
|
|
var redis = require('redis'),
|
|
client = redis.createClient();
|
|
|
|
// Extend the RedisClient prototype to add a custom method
|
|
// This one converts the results from 'INFO' into a JavaScript Object
|
|
|
|
redis.RedisClient.prototype.parse_info = function (callback) {
|
|
this.info(function (err, res) {
|
|
var lines = res.toString().split('\r\n').sort();
|
|
var obj = {};
|
|
lines.forEach(function (line) {
|
|
var parts = line.split(':');
|
|
if (parts[1]) {
|
|
obj[parts[0]] = parts[1];
|
|
}
|
|
});
|
|
callback(obj);
|
|
});
|
|
};
|
|
|
|
client.parse_info(function (info) {
|
|
console.dir(info);
|
|
client.quit();
|
|
});
|
|
|