1 Star 0 Fork 0

wscluster / wsc-redis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 706 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jealous 提交于 2017-07-05 18:52 . Rename the package
var util = require('util');
var redis = require('redis');
var EventEmitter = require('events').EventEmitter;
function Broker() {
EventEmitter.call(this);
this._pubClient = redis.createClient.apply(redis, arguments);
this._subClient = redis.createClient.apply(redis, arguments);
this._subClient.on('message', this.emit.bind(this, 'message'));
}
Broker.prototype.subscribe = function (channel) {
this._subClient.subscribe(channel);
};
Broker.prototype.unsubscribe = function (channel) {
this._subClient.unsubscribe(channel);
};
Broker.prototype.publish = function (channel, message) {
this._pubClient.publish(channel, message);
};
util.inherits(Broker, EventEmitter);
module.exports = Broker;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/wscluster/wsc-redis.git
git@gitee.com:wscluster/wsc-redis.git
wscluster
wsc-redis
wsc-redis
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891