<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; ">I now see 'session' appearing in the bin entries 3 times, which I assume to be heading in the right direction. I have the following code fire on hook_init:</div><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; "><br></div><div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; // if there is no key use the user info</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; if (!$key) {</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; if (is_object($user) &amp;&amp; $user-&gt;sid) $key = $user-&gt;sid;</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; else return;</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; drupal_set_message('user=' . $key);</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; }</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style=""><br style=""></font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style=""><br style=""></font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; if (($sessionData = dmemcache_get($key, 'session')) == NULL) {</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; drupal_set_message('Memcache write: ' . ($mw = dmemcache_set($key, $user, 60, 'session')) ? 'success' : 'fail');</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; $sessionData = dmemcache_get($key, 'session');</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; }</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; drupal_set_message('&lt;pre&gt;' . print_r($sessionData,1) . '&lt;/pre&gt;');</font></div><div style=""><br></div><div style="">So basically if the current session is not cached (the read comes back empty), I have memcache set it and read it again. The second read is successful. However, reloading the page Always displays 'success', which means the write is always occurring, which means the cache retrieval is failing either because I'm doing it wrong or because it's not really cached (though I don't know why the second read would work each time).</div><div style=""><br></div><div style="">Of course, I don't want to request the session to be cached.. it should be automatic.</div><div style=""><br></div></div>
<blockquote id="replyBlockquote" webmail="1" style="border-left-width: 2px; border-left-style: solid; border-left-color: blue; margin-left: 8px; padding-left: 8px; font-size: 10pt; color: black; font-family: verdana; ">
<div id="wmQuoteWrapper">
-------- Original Message --------<br>
Subject: [support] Getting memcache to cache sessions<br>
From: &lt;<a href="mailto:jeff@ayendesigns.com">jeff@ayendesigns.com</a>&gt;<br>
Date: Tue, May 15, 2012 12:03 pm<br>
To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>
<br>
<span style="font-family:Verdana; color:#000000; font-size:10pt;"><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; ">I have memcache installed, and the UI turned on, and it generates statistics for get, set, etc. However it does not generate anything for session caching, and a call to dmemcache_get(session id, 'session') comes back empty.</div><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; ">Here are the applicable settings from settings.php</div><div style="color: rgb(0, 0, 0); font-family: verdana, geneva; font-size: 10pt; "><br></div><div><div style=""><span class="Apple-style-span" style="font-family: verdana, geneva; font-size: small; " mce_fixed="1">$conf['cache_inc'] = $_SERVER['cache_inc']; 'this is set elsewhere and contains the valid path</span></div><div style=""><span class="Apple-style-span" style="font-family: verdana, geneva; font-size: small; " mce_fixed="1">$conf['memcache.hash_strategy']="consistent";</span></div><div style=""><span class="Apple-style-span" style="font-family: verdana, geneva; font-size: small; " mce_fixed="1">if (isset($_SERVER['HTTP_USER_AGENT']) &amp;&amp; !preg_match("/(?:cron\.php|install\.php)/", $_SERVER['REQUEST_URI'])) {</span></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; if (isset($_SERVER['HTTP_HOST'])) {</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; $conf += array(</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'cache_default_class' =&gt; 'MemCacheDrupal',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'session_inc' &nbsp; &nbsp; &nbsp;=&gt; './sites/all/modules/contrib/memcache/memcache-session.inc',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'memcache_servers' =&gt; array(</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'localhost:11211' =&gt; 'default',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'localhost:11215' =&gt; 'session',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'localhost:11216' =&gt; 'users',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ),</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'memcache_bins' =&gt; array(</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'cache' =&gt; 'default',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'session' =&gt; 'session',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'users' =&gt; 'users',</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;),</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; );</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2" style="">&nbsp; }</font></div><div style=""><font class="Apple-style-span" face="verdana, geneva" size="2"><br></font></div></div></span> <hr>-- <br>
[ Drupal support list | <a href="http://lists.drupal.org">http://lists.drupal.org</a>/ ]
</div>
</blockquote></span></body></html>