variable memcached_key

Maxim Dounin mdounin at mdounin.ru
Mon Jul 21 06:28:43 MSD 2008


Hello!

On Mon, Jul 21, 2008 at 04:09:58AM +0200, Arteta Arteta wrote:

>Hello ou bonjour, je suis Fran??ais, donc google va m'aider ^^
>
>I memcached installed on a production server.
>With libmemcached I sent pictures in memory:
>
>:/usr/local/nginx/conf# /usr/local/libmemcached/bin/memcp
>/data/www/logos/logo.jpg --servers=127.0.0.1:11211

[...]

>The problem was that the images are at the "root" in memory, So when I
>put this:
>
>location ~ \.(gif|jpg|jpeg)$ {
>       set  $memcached_key $args;
>       memcached_pass   127.0.0.1:11211;
>    }
>
>I have this to log:
>
>2008/07/21 04:03:11 [info] 21310#0: *6 key: "/logos/logo.jpg" was not
>found by memcached while reading response header from upstream, client:
>XXXXXXXXX, server: XXXXXX, request: "GET /logos/logo.jpg HTTP/1.1",
>upstream: "memcached://127.0.0.1:11211", host: "XXXXXXX:85", referrer:
>"http://XXXXXX:85/"
>
>2008/07/21 04:03:11 [info] 21310#0: *4 key: "/logos/logo21.jpg" was not
>found by memcached while reading response header from upstream, client:
>XXXXXX, server: XXXXXXXX, request: "GET /logos/logo21.jpg HTTP/1.1",
>upstream: "memcached://127.0.0.1:11211", host: "XXXXXXX:85", referrer:
>"http://XXXXXXXX:85/"
>
>And when I test by placing:
>
>       set  $memcached_key logo.jpg;
>       memcached_pass   127.0.0.1:11211;
>
>This works well.
>
>So my question, is there a variable for only the filename, or a trick to
>get it back.

     if ($uri ~= "([^/]+$)") {
         set $memcached_key $1;
     }
     memcached_pass ...;

See http://wiki.codemongers.com/NginxHttpRewriteModule for details 
about ways to manipulate variables.

See http://wiki.codemongers.com/NginxHttpCoreModule for details 
about available generic variables.

Maxim Dounin





More information about the nginx mailing list