is it possible to connect to memcached and check in access phase?

Johan Bergström johan at bergstroem.nu
Wed Aug 26 23:54:02 MSD 2009


Bumping an old thread here - but I recently stumbled over a similar  
issue:
I want to do stuff depending on if a key exists in memcached or not,  
something in style with

if ($key) {
  return 404;
} else {
  proxy_pass foo.bar;
}

..which is very similar to below. Has anyone solved this yet?

Thanks,
Johan Bergström

On Feb 22, 2009, at 18:25 , Huy Phan wrote:

> I'm trying to build a nginx module for the need of my workflow :
> In access phase :
> 1. Connect to  the memcached and get value for key "abcxyz"
> 2. If the value is 1, return NGX_HTTP_OK ( 200 )
> 2. If the value is 0, return NGX_HTTP_FORBIDDEN ( 403 )
>
> As far as I know, upstream is the only way to connect to memcached,  
> but it's using callback mechanism ( asynchronous request ) .
> Is it possible to connect to the memcached and wait for result  
> ( synchronous ) , then return corresponding code right inside  
> handler function of access phase ?
>






More information about the nginx mailing list