Skip to content

Instantly share code, notes, and snippets.

@rogerdudler
Created August 19, 2011 08:47
Show Gist options
  • Save rogerdudler/1156361 to your computer and use it in GitHub Desktop.
Save rogerdudler/1156361 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