I am using memcache for caching in my rails app and currently I have a dev and a production environment. I would like to run the dev environment without caching so that I can debug more easily but I wanna enable the caching in production obviously. I am using github and capistrano for deployment. Without doing a check at every statement where I can potentially dig into the cache, is there any way of handling this more gracefully or globally? if env == ''dev'' @post = Post.all else //get @post from cache en -- 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.
badnaam wrote:> I am using memcache for caching in my rails app and currently I have a > dev and a production environment. > > I would like to run the dev environment without caching so that I can > debug more easily but I wanna enable the caching in production > obviously. I am using github and capistrano for deployment. > > Without doing a check at every statement where I can potentially dig > into the cache, is there any way of handling this more gracefully or > globally? > > if env == ''dev'' @post = Post.all else //get @post from cache enRails turns caching off by default in the development environment, if I remember correctly. If not, you can certainly turn it off yourself in config/environments/development.rb . Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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.
Assuming you are using standard page/fragement/action caching you can just set config.action_controller.perform_caching = false in your development environment file. If you are making direct calls to Rails.cache you can use a cache store stub in development. I just did this today for my test environment Details in my post earlier today http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/b8603c94ac08940a -- 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 understand how to turn caching on or off. Well let me explain.
let''s say if I am using memcache and I have a post listing page that
uses the following method. Now If I want to not use caching in
development I will have to write this method without the CACHE.fetch?
So basically, I am doing a if/else in every method do check if it''s
dev or prod and then either get the collection/fragment from the CACHE
or not. This seems ugly, wondering if there is a better way.
def get_all_post
CACHE.fetch("all_posts") {Post.all}
end
On Sep 2, 9:16 am, Tony Primerano
<tony.primer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Assuming you are using standard page/fragement/action caching you can
> just set
>
> config.action_controller.perform_caching = false
>
> in your development environment file. If you are making direct calls
> to Rails.cache you can use a cache store stub in development.
>
> I just did this today for my test environment
>
> Details in my post earlier today
>
> http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.