ruby on rails - How can I prevent the odd insertion of :@new_record when cache hits in Dalli? -


i'm implementing caching on heroku using dalli , memcachier, , when cache hit it's adding symbol returned array (or hash, in different example). symbol, :@new_record, has nothing know of results i'm returning, inserted on different types of cache fetches, , haven't been able find else on so/google issue. codebase-wide find returns no results "new_record".

this addition has happened in 2 places i've tried add caching. don't know how prevent happening in first place, dodge effects in particular use checking class of each record in returned set, , not rendering supplier's profile if it's not supplier. ugly solution, , i'd solve problem @ source.

please let me know if have additional questions / need me post more information, , help.


the method i'm using caching in:

  #this slow, need store somewhere   def self.set_for_index(index_name)     guide = index_holder[index_name]     return false if guide.nil?     haves, have_nots, countries = guide[0], guide[1], guide[2]     holder = []     supplier_set = rails.cache.fetch("set_for_index_#{index_name}", :expires_in => 24.hours) {       supplier.find_each |s|         if (             s.profile_visible ,             (countries == [] or (s.address , countries.include?(s.address.country))) ,             !(haves.map{ |h| s.has_tag?(tag.find_by_name(h).id) }.include?(false)) ,             !(have_nots.map{ |h| s.has_tag?(tag.find_by_name(h).id) }.include?(true))           )             holder << s         end       end       holder     }     return supplier_set   end 

i'm screening out :@new_record right using last line of code:

def self.visible_profiles_sorted(index_name)       profiles = supplier.set_for_index(index_name)        answer = {}        if !(profiles.nil? or profiles == [])         profiles.each |s|             #block odd error cache appends :@new_record after last result           next if !s.is_a?(supplier) or s.address.nil? or s.address.country.nil? ... 

the error, if don't screen out @new_record [this not cutting line above code, rather place tried use caching class-based test wasn't feasible]:

2013-08-28t20:50:00.446550+00:00 heroku[web.1]: state changed starting 2013-08-28t20:50:06.774001+00:00 app[web.1]: dalli/sasl authenticating af5c2c 2013-08-28t20:50:06.777925+00:00 app[web.1]: dalli/sasl: af5c2c 2013-08-28t20:50:06.807129+00:00 app[web.1]: started "/suppliers" 70.36.146.74 @ 2013-08-28 20:50:06 +0000 2013-08-28t20:50:10.671553+00:00 app[web.1]:  2013-08-28t20:50:10.671553+00:00 app[web.1]:     37:                                    <td> 2013-08-28t20:50:10.671553+00:00 app[web.1]: actionview::template::error (undefined method `name' :@new_record:symbol): 2013-08-28t20:50:10.671553+00:00 app[web.1]:     39:                                            <%= link_to s.name, supplier_profile_path(s.name_for_link) %> 2013-08-28t20:50:10.671553+00:00 app[web.1]:     40:                                            <%= image_tag  

application.rb's relevant bit:

module partreach   class application < rails::application      config.cache_store = :dalli_store 

production.rb's relevant bit:

partreach::application.configure   # settings specified here take precedence on in config/application.rb    # code not reloaded between requests   config.cache_classes = true    # full error reports disabled , caching turned on   config.consider_all_requests_local       = false   config.action_controller.perform_caching = true 

gemfile's relevant bit:

gem 'dalli', '2.6.4' #https://devcenter.heroku.com/articles/building-a-rails-3-application-with-memcache gem 'memcachier', '0.0.2' #https://devcenter.heroku.com/articles/building-a-rails-3-application-with-memcache 

i ran same thing. listed on on issues page dalli -- it's not limited it.

you can find more info here: https://github.com/mperham/dalli/issues/250

and on rails issues page too: https://github.com/rails/rails/issues/8020

and workaround resolved me: https://github.com/rails/rails/issues/10322#issuecomment-16913855


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -