Note that there are some explanatory texts on larger screens.

plurals
  1. PORails with Memcache returning wrong cached object?
    text
    copied!<p>I have a fairly large Rails app, which uses memcached on a seperate server as its cache store. </p> <p>The problem is that I randomly get errors in the production environment which <em>seem</em> to indicate that memcached is returning an incorrect object.</p> <p>Examples:</p> <p>In this example, <code>current_site</code> is a helper method which accesses a method on the <code>Site</code> model that uses Rails.cache to cache the model</p> <pre><code>ActionView::TemplateError in ListingsController#edit undefined method `settings' for #&lt;String:0xb565f8a0&gt; On line #12 of app/views/layouts/site.html.erb 9: &lt;meta name="robots" content="noodp, all" /&gt; 10: &lt;meta name="distribution" content="Global" /&gt; 11: 12: &lt;% unless current_site.settings[:google_webmaster_verification_code].blank? %&gt; 13: &lt;meta name="verify-v1" content="&lt;%= current_site.settings[:google_webmaster_verification_code] %&gt;" /&gt; 14: &lt;% end %&gt; 15: </code></pre> <p>contrasted with....</p> <pre><code>ActionView::TemplateError in ApplicationController#not_found undefined method `settings' for #&lt;Category:0xd5c6c34&gt; On line #12 of app/views/layouts/site.html.erb 9: &lt;meta name="robots" content="noodp, all" /&gt; 10: &lt;meta name="distribution" content="Global" /&gt; 11: 12: &lt;% unless current_site.settings[:google_webmaster_verification_code].blank? %&gt; 13: &lt;meta name="verify-v1" content="&lt;%= current_site.settings[:google_webmaster_verification_code] %&gt;" /&gt; 14: &lt;% end %&gt; 15: </code></pre> <p>When both should be returning a <code>Site</code> model!</p> <p>Another example of cache behaving strangely:</p> <pre><code>ActionView::TemplateError in AccountsController#show can't convert Category into String On line #141 of app/views/layouts/site.html.erb 138: &lt;li&lt;%= class="first" if i == 0 %&gt;&gt;&lt;%= link_to top_level_category.title, top_level_category.path %&gt;&lt;/li&gt;&lt;% end %&gt; 139: &lt;/ul&gt; 140: &lt;% end %&gt; 141: &lt;% cache bottom_pages do %&gt; 142: &lt;ul&gt;&lt;% Page.top_level.active.show_in_navigation.find(:all, :include =&gt; :slugs).each_with_index do |top_level_page, i| %&gt; 143: &lt;li&lt;%= class="first" if i == 0 %&gt;&gt;&lt;%= link_to top_level_page.title, top_level_page.path %&gt;&lt;/li&gt;&lt;% end %&gt; 144: &lt;/ul&gt; </code></pre> <p>Has anyone encountered something like this before? Anyone have thoughts on diagnosing this unreplicable problem!? I've tried switching out memcached client gems, thinking maybe it was a weird bug, but this didn't have any effect! Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload