SSSloppy,<br><br>In short, using the memcached backend with NginX is just like publishing to flat-files except your storage engine is in memcached and not the local filesystem.<br><br>Going deeper, your forum software using memcached helps it cache specific query results so it need not go to the database.  NginX&#39;s memcached module serves content directly from memcached, completely bypassing your application and touching the database not at all.  This means to utilize it with your forum, you will need to publish, or store, the output for each URI in memcached.  In Python this can be accomplished very easily with a simple WSGI middleware.  In PHP you will need to use the output buffering functions (ob_*).  In other stuff, others.  <br>
<br>Now the more in depth how to...<br><br>The NginX Memcached Module (documented <a href="http://wiki.nginx.org/NginxHttpMemcachedModule">http://wiki.nginx.org/NginxHttpMemcachedModule</a> and <a href="http://sysoev.ru/nginx/docs/http/ngx_http_memcached_module.html">http://sysoev.ru/nginx/docs/http/ngx_http_memcached_module.html</a> in original Russian) simply turns memcached into a backend for NginX to reverse proxy to, much like another HTTP server or fastcgi, etc.<br>
<br>What this means is that NginX will attempt to serve resources from memcached keys.  The example from the example from the wiki is pretty succinct and very complete:<br><pre class="code"><a href="http://wiki.nginx.org/NginxHttpCoreModule#server"><span class="kw3">server</span></a> <span class="br0">{</span><br>
  <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> / <span class="br0">{</span><br>    <a href="http://wiki.nginx.org/NginxHttpRewriteModule#set"><span class="kw22">set</span></a> <span class="re0">$memcached_key</span> <span class="re0">$uri</span>;<br>
    <a href="http://wiki.nginx.org/NginxHttpMemcachedModule#memcached_pass"><span class="kw20">memcached_pass</span></a>     name:<span class="nu0">11211</span>;<br>    <a href="http://wiki.nginx.org/NginxHttpCoreModule#default_type"><span class="kw3">default_type</span></a>       text/html;<br>
    <a href="http://wiki.nginx.org/NginxHttpCoreModule#error_page"><span class="kw3">error_page</span></a>         <span class="nu0">404</span> = /fallback;<br>  <span class="br0">}</span><br> <br>  <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> = /fallback <span class="br0">{</span><br>
    <a href="http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass"><span class="kw21">proxy_pass</span></a> backend;<br>  <span class="br0">}</span><br><span class="br0">}</span></pre>[apologies if you don&#39;t have HTML mail]<br>
Here we see that the memcached key is set to the URI requested.  Next is the memcached_pass directive which is like the rest of the *_pass directives (proxy_pass, fastcgi_pass, etc) in that it tells which backend to go to.  The rest is just setting the default type (In my experience it seems MIME Type is not checked from memcached) and setting a fallback location to serve from in case the content is not in memcached yet.<br>
<br>What this setup then assumes is that the backend (in your case, the forum software) will publish the page output into memcached in the key that is the URI.  As I previously mentioned, the best way to go about this is with some kind of middleware or output buffering, in my experience.  The problem with the forum is it might need to be a little more complicated, depending on how you want to do it.<br>
<br>If you want to just cache page output for a minute or two, it should be as simple as pushing into memcached with a minute expiration time, nothing else need be done except not serving POST requests from memcached and disallowing your very dynamic pages with the same URI from being cached (so like /forum/post would be not cached but /forum/main-category/this-is-a-thread would).<br>
<br>However, if you want to &quot;cache forever&quot; it gets a lot more complicated.  You&#39;ll need to do the above, without the minute limit, and in addition to that, you&#39;ll need to include code so that every action that changes something on a page causes a republication.  This can obviously get pretty hairy if your application was not designed with such a thing in mind in the first place.<br>
<br>At any rate, good luck!<br><br>- Merlin<br><br><div class="gmail_quote">On Wed, Apr 1, 2009 at 3:31 PM, SSSlippy <span dir="ltr">&lt;<a href="mailto:nginx-forum@nginx.us">nginx-forum@nginx.us</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Ok I am trying to figure out how to use the memcache module to my advantage.  I run multiple forums that can put their &quot;datastore&quot; into memcached already.<br>

<br>
Would just adding the memcached server info help?<br>
<br>
Confused on how to make this work.<br>
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,738,738#msg-738" target="_blank">http://forum.nginx.org/read.php?2,738,738#msg-738</a><br>
<br>
<br>
</blockquote></div><br>