Thank you very much for detailed answer!
I'll try to modify this library as you suggested.
As for memcached, yes, couchbase supports memcached protocol, but with
moxi software which is not ready for production. That is why I decided
to use pure couchbase client.
As for the nginx-libcocubase library
(https://github.com/couchbaselabs/couchbase-nginx-module), it is very
buggy. I guess developers still didn't manage to implement
libcouchbase library with nginx event model.
Regards!
2014-04-04 23:21 GMT+04:00 Yichun Zhang (agentzh) <age...@gmail.com>:
> Hello!
>
> On Fri, Apr 4, 2014 at 7:59 AM, kay wrote:
>> I'm trying to use https://github.com/chrhlnd/lualibcbase with lua module
>>
>> Actually I already got results, but I have few questions:
>>
>> * there are two types of lua binding library: sync and async. which
>> should I use?
>
> Neither. This library will always block the NGINX worker process
> because it knows nothing about ngx_lua's cosocket API:
>
> https://github.com/chaoslawful/lua-nginx-module#ngxsockettcp
>
> Because the cosocket API is mostly compatibilty to LuaSocket's API,
> existing Lua libraries based on the LuaSocket API can be made
> nonblocking in openresty with minor adjustments.
>
>> * where should I create a connection? In init_by_lua? Or where? I
>> should not create new connection for each request.
>>
>
> Nonblocking cosocket objects in openresty can only be per-request.
> Though you can share and reuse the underlying TCP connections via the
> cosocket pool mechanism:
>
> https://github.com/chaoslawful/lua-nginx-module#tcpsocksetkeepalive
>
> I'm cc'ing the openresty-en mailing list:
> https://groups.google.com/group/openresty-en And some people there
> might know a read-to-use nonblocking Lua driver for openresty +
> couchbase. You're also recommended to join the list and ask such
> questions there.
>
> I'm not sure if couchbase supports the memcached wire protocol. If
> yes, then you can use the standard lua-resty-memcached library
> directly:
>
> https://github.com/agentzh/lua-resty-memcached#readme
>
> Regards,
> -agentzh