很早之前就因为nosql就听说了redis,直到去年才真正去了解,只能说相见恨晚。

因为数据库相关,我以为这应该是个庞然大物,万万没想到,源码不到2M,所以,我不知道该说啥了。。。

还是来点靠谱的:

 /* Include the best multiplexing layer supported by this system.
* The following should be ordered by performances, descending. */
#ifdef HAVE_EVPORT
#include "ae_evport.c"
#else
#ifdef HAVE_EPOLL
#include "ae_epoll.c"
#else
#ifdef HAVE_KQUEUE
#include "ae_kqueue.c"
#else
#include "ae_select.c"
#endif
#endif
#endif

按照redis作者的排位,从上到下,性能是递减的,也就是evport>epoll>kqueue>select。libevent库上面有个benchmark,可能比较权威,http://libevent.org/ (那破图我能说点什么吗)

这个排位估计众说纷纭,对我来说,够用就好。

下面是redis定义的事件轮询函数原型:

 /* Prototypes */
aeEventLoop *aeCreateEventLoop(int setsize);
void aeDeleteEventLoop(aeEventLoop *eventLoop);
void aeStop(aeEventLoop *eventLoop);
int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask,
aeFileProc *proc, void *clientData);
void aeDeleteFileEvent(aeEventLoop *eventLoop, int fd, int mask);
int aeGetFileEvents(aeEventLoop *eventLoop, int fd);
long long aeCreateTimeEvent(aeEventLoop *eventLoop, long long milliseconds,
aeTimeProc *proc, void *clientData,
aeEventFinalizerProc *finalizerProc);
int aeDeleteTimeEvent(aeEventLoop *eventLoop, long long id);
int aeProcessEvents(aeEventLoop *eventLoop, int flags);
int aeWait(int fd, int mask, long long milliseconds);
void aeMain(aeEventLoop *eventLoop);
char *aeGetApiName(void);
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep);
int aeGetSetSize(aeEventLoop *eventLoop);
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);

看到这个让我想起了大概是2007年微软推出mvc三层架构里的数据库访问层,封装各类数据库api,来实现一个抽象统一的数据访问中间层,

那么,在这里对不同socket IO复用实现也进行了统一的封装。或者很类似设计模式里的bridge模式。

多的我也不说了,参考大神的博客:

http://www.kegel.com/c10k.html

http://pl.atyp.us/content/tech/servers.html

最新文章

  1. WAMP2.5 Forbidden
  2. 【IOI2000】邮局设置问题
  3. VS-Visual Studio-IIS Express 支持局域网访问
  4. 使用 IL 实现类型转换
  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
  6. 浅谈JavaScript计时器
  7. response.redirect和server.Transfer的差别详解
  8. IE6的那些css常见bug(汇总)
  9. robotframework的分支和循环
  10. UI—视图的生命周期
  11. Java 异常处理笔记
  12. BZOJ2282: [Sdoi2011]消防
  13. 手把手 学习Git
  14. 网站开发进阶(二十三)Address already in use: JVM_Bind <null>:8088
  15. FLASK简单入门
  16. Python爬取网络图片
  17. Python关于类的实操
  18. interface接口——公共规范标准
  19. adjustPan 没作用
  20. android开发(34) 自定义 listView的分割线( 使用xml drawable画多条线)

热门文章

  1. MyBatis简单了解
  2. 第32章 TIM—高级定时器—零死角玩转STM32-F429系列
  3. 九九乘法表(Python实现)
  4. JAVA通用BaseServlet的产生和代码实现
  5. SpringBoot学习11:springboot异常处理方式1(自定义异常页面)
  6. vue中登录模块的插件封装
  7. SpringMVC-实现PUT请求上传文件(转)
  8. JS - 属性描述符各配置的默认值的注意事项
  9. Servlet学习笔记06——什么是转发,路径,状态管理?
  10. GNU 汇编 协处理器指令