说明:Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.
在nodejs的官方文档中,明确写出了node的一个特性是event-driven(事件驱动),可见其非常重要。查看源码,我们可知其事件机制为用js写的EventEmitter类,写得非常优雅且应用了发布/订阅模式。
通过实现一个简易的、具有发布/订阅模式的事件机制,以此来理清EventEmitter类的实现 <weixin_38654348> 上传 | 大小:74kb
说明:nodejs redis 发布订阅机制封装
最近项目使用redis,对publish 和 subscribe的使用进行了了解,并进行了封装。
var config = require('../config/config');
var log = require("./loghelp");
var redis = require("redis");
function initialclient(param) {
var option={ host: config.redis.host, p <weixin_38751537> 上传 | 大小:43kb