Hello!
2014-07-22 22:22 GMT-07:00 Lei King:
> 这个模块的get要把key escape后再进行get,如果memcache里的key我存的时候没用 lua-resty-memcached,
> 比如我用的是lua+luamemcache, 是不进行escape的,
>
> 我的意思是章哥是不是给 lua-resty-memcached加个参数,表明key是否需要进行escape。
>
我之前不是已经给你贴过 new 方法的文档了;lua-resty-memcached 已经通过 new 方法的选项提供了自定义 key
转换方法的参数了。你为什么不能点进去看一眼呢?再贴一下文档链接:
https://github.com/openresty/lua-resty-memcached#new
在这里再引用一下相关的部分:
“It accepts an optional opts table argument. The following options are
supported:
* key_transform
an array table containing two functions for escaping and unescaping
the memcached keys, respectively. By default, the memcached keys will
be escaped and unescaped as URI components, that is
memached:new{
key_transform = { ngx.escape_uri, ngx.unescape_uri }
}
”
所以,如果你不希望转义的话,这么初始化你的 memcached 对象就好了:
local function id(key) return key end
local memc, err = memcached:new{ key_transform = { id, id } }
另外,请不要把这里当作即时通信软件来用,不停地重复发帧,很是骚挠。
Regards,
-agentzh