w-redis

0.0.1 • Public • Published

w-redis

npm license

node-redis 扩展补充 Promise 对象 (node-rdis 文档)

说明

w-redis 的指令方法最后一个回调参数有与 node-redis 功能一样

w-redis 的指令方法最后一个无回调参数 将返回Promise对象

安装

$ npm install w-redis

使用

var config = {
  host: '127.0.0.1',
  port: 6379,
  db: 0
};

var redis = require('w-redis');
var client = redis.createClient(config);
var key = 'key:test';
new Promise(function (resolve, reject) {
  resolve();
}).then(function (reply) {
  return client.set(key, 'value #1');
}).then(function (reply) {
  console.log('#1 %j', reply);
  return client.get(key);
}).then(function (reply) {
  console.log('#2 %j', reply);
  return client.multi()
    .set(key, 'value #2')
    .get(key)
    .exec();
}).then(function (replys) {
  client.quit();
  console.log('replys: %j', replys);
}).catch(function (err) {
  client.quit();
  console.error('error: %j', err);
});

Readme

Keywords

Package Sidebar

Install

npm i w-redis

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • meglad