views:

30

answers:

1

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 end

A: 

You may want to consider adding a "flush_all" some where in your capistrano deployment script. This should help in removing "old" cache content for your capistrano development pushes.

You may also want to consider overloading/aliasing the get/set CACHE functions and just replacing the code where you are doing the caching. I haven't seen a good implementation of this.

You may also want to overload the Rails.logger and add in display of the memcache code where you want it

Rails.logger.memcache_display = true
..
..
Rails.logger.memcache_display = false

This doesn't answer your question, but this can help make debuging more easy.

Daniel