nanha
10/24/2011 - 1:33 AM

redis usage in node.js

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) { });