3 messages in ru.sysoev.nginxRe: how can i use memcached_module
FromSent OnAttachments
焦胜强May 6, 2007 11:11 am 
Liang JinMay 6, 2007 4:27 pm 
焦胜强May 6, 2007 9:35 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: how can i use memcached_moduleActions...
From:Liang Jin (mywe@public.gmane.org)
Date:May 6, 2007 4:27:23 pm
List:ru.sysoev.nginx

Hi,

First of all, you need to configure Memcached daemon. In the config file you showed, it is located at localhost:10000 .

So when a client visit your site, nginx will try this Memcached server to fetch the key defined in $memcached_key. If the client requests domain1.com/path1/file1.php

This URL would be the key in Memcached cache, that stores the HTML cache file for that page.

If nginx cannot find the key in the Memcached cache, it will return an 404 error, which in the config file will fallback to the backend proxy.

The first time when a visitor views the page, it will always fallback to the backend. At that time, you should add in your PHP code to store the HTML page in the Memcached with the correct key. So the next time, the page will be served by nginx using the contents in the Memcached cache.

Does it make sense? For PHP memcached client, you can use the official php-memcache module.

-Liang

On 5/6/07, 焦胜强 <jia@mail.51.com> wrote:

HI: how can use the memcached_module in php? can someone give a example? I can not understand this configfile: ... upstream backend { server localhost:80; } ... location /memcached/ { internal; ssi on; set $memuri $uri; set $memcached_key "$memuri"; memcached_pass localhost:10000; error_page 404 =200 /memcached-miss$memuri; } ... location /memcached-miss/ { internal; ssi on; rewrite ^/memcached-miss/(.*)$ /$1 break; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://backend; proxy_redirect off; }