Search code examples
ruby-on-railsrubyruby-on-rails-3caching

Rails: control file store cache size


The documentation for the file-based cache in rails says:

Note that the cache will grow until the disk is full unless you periodically clear out old entries.

Unfortunately it doesnt give any information about how to clear old entries periodically. Does setting an appropriate value for :expires_in do the job or is there some other sort of black magic behind clearing the cache?

Also, the documenation gives an option to limit the memory-based cache in size:

config.cache_store = :memory_store, { size: 64.megabytes }

Does this also work for the file based cache? And even more importantly, what happens when the cache growths below that size limit? Does it remove old cached values or will it throw some kind of exception?

thanks in advance, danijoo


Solution

  • Yes the limit applies in case of file-based cache too. And yes a value for :expires_in will do the job.

    When this limit is reached, no further stuff will be cached. No exception is thrown.