Access ResponseCache instance during extension activation?

This is kind of a weird question, but is there a way to access the
current ResponseCache instance during the activation method of an
extension?

I’d like to be able to call its clear method to empty the cache when I
start up a specific extension, so I don’t have to manually empty it.

Thanks!

  • Dave

ResponseCache.instance should do the trick.

Sean

Sean C. wrote:

ResponseCache.instance should do the trick.

Earlier today I tried:

cache = ResponseCache.instance
cache.clear

… and also …

ResponseCache.instance.clear

Both deleted all the files from my /public directory instead of my
/cache directory. What seemed to be happening was that I was creating a
new instance of ResponseCache, which I believe by default Rails assigns
/public as the cache directory, hence the killing of my files.

This seemed weird to me because the following (when used during any
extension’s activation method) properly overrides the value set in
/config/environments/development.rb for all pages in the website:

ResponseCache.defaults[:perform_caching] = false

  • Dave