当前位置:Gxlcms > mysql > 再次改动了tornado-memcache

再次改动了tornado-memcache

时间:2021-07-01 10:21:17 帮助过:58人阅读

在上次(http://wangxu.me/blog/p/758)之后,再次改动了 tornado-memcache 模块,commit 信息如下: Add gets method and simplify connection estabilish - simplify connection estabilish procedure, as tornado.iostream permit write before connection

在上次(http://wangxu.me/blog/p/758)之后,再次改动了 tornado-memcache 模块,commit 信息如下:

Add gets method and simplify connection estabilish

- simplify connection estabilish procedure, as tornado.iostream
  permit write before connection estabilished, I removed the
  callback and connection timeout procedure in _get_server()
- add `gets(self, keys, callback, failcallback)` method, receive
  a list of keys as parameter and return a dictionary of results
  result = {key1:value1, key2:value2...}, only return the got
  keys from memcached
- some debug info, might be cleanup later
Signed-off-by: Wang Xu 

简单地说就是两件事情:

  • 读了文档,发现 tornado 的 iostream 允许在连接建立未完成的时候就write,既然我之前已经用 iostream 管理 socket 了,这里就省掉上次在这里加上的callback 和 timeout,直接 write command,等 write 的超时或返回就好了;
  • 读了memcached 协议,发现取信息(get),是支持一次取多条信息的,于是加入了这个支持,这样,批处理操作时会提高不少效率。

里面还插入了好多调试的时候的 debug 信息,差不多都注掉了,回头都稳定了再清理一下。

嗯,代码都在 github 了:https://github.com/gnawux/tornado-memcache

人气教程排行