# Set generated PHP output to Memcached server by Nginx transparently

**URL:** <https://www.ruby-forum.com/t/set-generated-php-output-to-memcached-server-by-nginx-transparently/193413>\
**Category:** NGINX\
**Created:** [August 17, 2010, 11:18am UTC](https://www.ruby-forum.com/t/set-generated-php-output-to-memcached-server-by-nginx-transparently/193413 "2010-08-17T11:18:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f08c70/32.png) [@jkuang](https://www.ruby-forum.com/u/jkuang)\
**Post date:** [August 17, 2010, 11:18am UTC](https://www.ruby-forum.com/t/set-generated-php-output-to-memcached-server-by-nginx-transparently/193413/1 "2010-08-17T11:18:51Z")

</div>

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:

> **[Set generated PHP output to Memcached server by Nginx transparently](https://forum.nginx.org/read.php?2,120613,120613#msg-120613)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![jkuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f08c70/32.png) [@jkuang](https://www.ruby-forum.com/u/jkuang)\
**Post date:** [August 19, 2010, 5:00am UTC](https://www.ruby-forum.com/t/set-generated-php-output-to-memcached-server-by-nginx-transparently/193413/2 "2010-08-19T05:00:38Z")

</div>

On Tue, Aug 17, 2010 at 5:18 PM, jkuang [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 🙂

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

---

<div class="post-metadata">

**Author:** ![jkuang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f08c70/32.png) [@jkuang](https://www.ruby-forum.com/u/jkuang)\
**Post date:** [August 22, 2010, 9:21pm UTC](https://www.ruby-forum.com/t/set-generated-php-output-to-memcached-server-by-nginx-transparently/193413/3 "2010-08-22T21:21:38Z")

</div>

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:

> **[Re: Set generated PHP output to Memcached server by Nginx transparently](https://forum.nginx.org/read.php?2,120613,122467#msg-122467)**
>
> 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...
