Skip to content

Instantly share code, notes, and snippets.

@nanha
Forked from rogerdudler/gist:1156361
Created October 24, 2011 01:33
Show Gist options
  • Save nanha/1308185 to your computer and use it in GitHub Desktop.
Save nanha/1308185 to your computer and use it in GitHub Desktop.
redis usage in node.js
// load redis client
var r = require('redis').createClient();
// set data for key
r.set('key', data);
// add data to key (list)
r.lpush('key', data);
// trim list to specific length
r.ltrim('key', 0, 1000);
// get value for key
r.get('key', function(err, data) { });
// increment value
r.incr('key', function (err, data) { });
// get range of data from list
r.lrange('key', 0, 5, function(err, data) { });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment