Using memcached from an Nginx module

David Birdsong david.birdsong at gmail.com
Wed Feb 12 22:08:26 UTC 2014


On Wed, Feb 12, 2014 at 1:45 PM, erankor2 <nginx-forum at nginx.us> wrote:

> Hi All,
>
> I want to develop an Nginx HTTP module that gets several values from
> memcache, performs some processing on them and returns the result to the
> client. I want all memcache operations to be performed asynchronously
> without blocking the worker process for maximum scalability. For this
> reason, I can't use libmemcached, and I'm looking for something that is
> built on Nginx.
> Is anyone familiar with a piece of code that does that ?
>
> Some more details:
> As I understand, it is theoretically possible to use the existing memcache
> upstream module for this, using subrequests. For example, to get a value I
> could start a subrequest for it and then handle the result when the
> subrequest completes. But this approach sounds a bit awkward, and it has
> the
> unnecessary overhead of processing all these dummy HTTP requests.
> What I would like ideally, is a module that exposes a function like -
> memcache_get(keyname, callback, context), where the callback is called
> either with the value if successful or an error code. I started writing
> such
> a module using the http_upstream module as reference, but found that it
> takes quite a bit of code to get it done, with lots of edge cases to handle
> (like timeouts in each one of the states)
>
>
yeah, use the http://openresty.org/ framework which includes:
https://github.com/agentzh/lua-resty-memcached

it couldn't be more perfect fit for what you're asking.


> Thank you !
>
> Eran
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,247481,247481#msg-247481
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140212/4b622925/attachment.html>


More information about the nginx mailing list