Skip to content

Instantly share code, notes, and snippets.

@actsasflinn
Created September 16, 2009 00:18
Show Gist options
  • Save actsasflinn/187770 to your computer and use it in GitHub Desktop.
Save actsasflinn/187770 to your computer and use it in GitHub Desktop.
# fix memory caching in dev mode
# put this in config/initializers/fix_caching_in_dev.rb
# Hopefully this won't be needed for long, this fixes cache calls (due to class reloading in dev)
# http://blog.bashme.org/2008/07/25/rails-21-model-caching-issue/
if ActiveSupport::Dependencies.mechanism == :load
module ActiveSupport
module Cache
class Store
def fetch(key, options = {})
log("write (will save)", key, nil)
(block_given?) ? yield : nil
end
def read(key, options = {})
log("read", key, options)
# Always return nil in dev!
write(key, nil)
return nil
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment