cofy-redis
v0.0.1
Published
cofy redis
Downloads
3
Readme
cofy-redis
cofy-redis
##Installation
$ npm install cofy-redis --save
Old methods not change.New methods invoke convention: yield obj.$asyncMethod
var redis = require('cofy-redis');
var redisClient = redis.createClient(6379,'localhost');
co(function*(){
yield redisClient.$set('k1' ,'v1');
var v = yield redisClient.$get('k1');
v.should.equal('v1');
yield redisClient.$del('k1');
//extra methods:
yield redisClient.$setJson('json' ,{name:1});
var v = yield redisClient.$getJson('json');
v.should.eql({name:1});
yield redisClient.$del('json');
});
//or you can use redis in old way
redisClient.set('k2' ,"v2" , function(e){
if(e){
return cb(e);
}
redisClient.get('k2' ,function(e,v){
if(e){
return cb(e);
}
v.should.equal("v2");
cb();
});
});
###ExtraMethods: redisClient
- $setJson(key , object) - Set json into redis.
- $getJson(key) - Get json from redis.