Skip to content

Commit

Permalink
Added multiGet command & tidied up
Browse files Browse the repository at this point in the history
  • Loading branch information
robtweed committed Oct 31, 2010
1 parent cfc9b5e commit e594ee3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions lib/mwire.js
Expand Up @@ -40,6 +40,8 @@ General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------
Build 0.0.2 - 31 October 2010
*/

var addCommands = function(redisClient) {
Expand All @@ -55,7 +57,8 @@ var addCommands = function(redisClient) {
"getglobals2",
"getjsonstring",
"setjsonstring",
"getsubscripts",
"getsubscripts",
"multiget",
"revorder",
"previous",
"query",
Expand Down Expand Up @@ -97,15 +100,6 @@ var addCommands = function(redisClient) {
});
};

redisClient.increment = function(globalName, subscripts, delta, callback) {
if (subscripts === '') subscripts = [];
var gloRef = globalName + JSON.stringify(subscripts);
redisClient.incrby(gloRef, delta, function (err, value) {
var json = {value:value};
callback(err,json);
});
};

redisClient.decrement = function(globalName, subscripts, delta, callback) {
if (subscripts === '') subscripts = [];
var gloRef = globalName + JSON.stringify(subscripts);
Expand Down Expand Up @@ -149,6 +143,12 @@ var addCommands = function(redisClient) {
});
};

redisClient.getGlobalsTest = function(callback) {
redisClient.getglobals2(function (err, array) {
callback(err,array);
});
};

redisClient.getJSON = function(globalName, subscripts, callback) {
if (subscripts === '') subscripts = [];
var gloRef = globalName + JSON.stringify(subscripts);
Expand Down Expand Up @@ -220,6 +220,14 @@ var addCommands = function(redisClient) {
});
};

redisClient.multiGetGlobal = function(json, callback) {
var jsonString = JSON.stringify(json);
redisClient.multiget(jsonString, function (err, jsonResponse) {
var jsonOut = JSON.parse(jsonResponse);
callback(err,jsonOut);
});
};

};

exports.addCommands = addCommands;
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ "name" : "node-mwire"
, "description" : "Extension to redis-node client for accessing GT.M and Cache Globals (via M/Wire interface)"
, "version" : "0.0.1"
, "version" : "0.0.2"
, "author" : "Rob Tweed <rtweed@mgateway.com>"
, "repository" :
{ "type" : "git"
Expand Down

0 comments on commit e594ee3

Please sign in to comment.