I''m trying to use redis-store as my cache_store. I also have an app_confirg.rb initalizer which loads a yaml file for config settings. In my redis.rb initializer I have: MyApp::Application.config.cache_store = :redis_store, APP_CONFIG[''redis''] However, this doesn''t appear to work. If I do Rails.cache in my rails console I can clearly see it''s using the ActiveSupport.Cache.FileStore as the cache store instead of redis. However, if I add the config in my application.rb file it works just fine, except the app config initializer is loaded after application.rb, so I don''t have access to it. Has anyone experienced this? I can''t seem to set a cache store in an initializer. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve also tried putting it in an after_initialize block and this doesn''t seem to work either. config.after_initialize do config.cache_store = :redis_store, APP_CONFIG[''redis''] end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bryan Crossland
2011-Apr-28 19:53 UTC
Re: Re: Can''t configure cach_store in an initializer
On Wed, Apr 27, 2011 at 6:10 PM, Jack Chu <kamuigt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve also tried putting it in an after_initialize block and this > doesn''t seem to work either. > > config.after_initialize do > config.cache_store = :redis_store, APP_CONFIG[''redis''] > end > >I think what you are looking for is described in the Cache-store section of the README document. It discusses how to configure it for multiple versions of Rails. https://github.com/jodosha/redis-store B. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks, but I think I found the solution and wrote it up on stackoverflow: http://stackoverflow.com/questions/5810289/setting-the-cache-store-in-an-initializer/5811913#5811913 Problem is that Rails initializes the cache_store before it loads the initlaizers in the initializers directory. I just found a way to load it in application.rb instead. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.