Set generated PHP output to Memcached server by Nginx transparently

Hi,

I have set up for NginxHttpMemcachedModule and it works great reading
output that I have set to Memcached server through my OWN PHP code. But
that means I have to modify my PHP code to make it happens and sometimes
it is not easy if the code is third party. I really think it would be
more beneficial if the NginxHttpMemcachedModule could set the generated
PHP output into Memcached server. By doing so, I don’t have to modify
PHP code to make it happen and it offers much better maintenance, using
Nginx server as the Memcache (cluster) Proxy.

Basically I need to be able to read PHP output from Memcached server:

  1. If there is PHP output in the Memcached server given $uri, use it
  2. If not, use fallback to the fastcgi or PHP-FPM
  3. The generated PHP output of step 2 is set to the Memcached server BY
    NGINX TRANSPARENTLY (no PHP code change but just Nginx configuration) to
    the Memcached server so it can be read next time on step 1.

I notice that there is another module call NginxHttpMemcModule. It seems
that it could do the trick but I am not sure by looking at the
configuration example in the wiki.

Could someone provide some insight on this issue?

Thanks!
– Jin Kuang

Posted at Nginx Forum:

On Tue, Aug 17, 2010 at 5:18 PM, jkuang [email protected] wrote:

I notice that there is another module call NginxHttpMemcModule. It seems
that it could do the trick but I am not sure by looking at the
configuration example in the wiki.

My ngx_memc module can do this job. Here’s more examples on my slides:

http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html#34

Using your arrow keys on the keyboard to switch slides :slight_smile:

It explains how to isssue various memcached commands and how to make
it proxy to a memcached cluster by hashing a custom key.

Cheers,
-agentzh

Thank you Mr. Agentzh. I have tried it couple times and it still fails.
I am quite sure it is related to my compilation and configuration.
Since I am still experimenting with Nginx overall, so I think I am ok
with proxy-cache for now as it is sufficient enough for my set up. Once
I am more comfortable with Nginx I will revisit your memc and srcache
modules.

Much appreciate for all the great work you did for the Nginx
development.

Sincerely,
– Jin Kuang

Posted at Nginx Forum: