Fix ActiveSupport::Cache::FileStore.cleanup to actually work. #3395

merged 1 commit into from Oct 21, 2011


None yet
5 participants

bdurand commented Oct 21, 2011

The cleanup method on ActiveSupport::Cache::FileStore on the 3.0 branch is defined but doesn't actually work. I have fixed the implementation so it can be used to clean up old cache entries either by expiration time or by how recently they've been used and added tests.

This method is needed to keep the cache from growing without bound until if fills up the disk.

The syntax is:

Rails.cache.cleanup(:expired_only => true)


Rails.cache.cleanup(:not_accessed_in => 2.days)

(Note: this request was originally opened in Lighthouse at

@josevalim josevalim added a commit that referenced this pull request Oct 21, 2011

@josevalim josevalim Merge pull request #3395 from bdurand/fix_file_store_cleanup
Fix ActiveSupport::Cache::FileStore.cleanup to actually work.

@josevalim josevalim merged commit 79d01a8 into rails:master Oct 21, 2011


guilleiguaran commented Oct 22, 2011

@bdurand looks like test_cleanup_with_not_accessed_in added in this pull request is failing on CI:!/rails/rails/builds/245309/L757

Can you take a look and fix it?


@josevalim josevalim added a commit that referenced this pull request Oct 25, 2011

@josevalim josevalim Revert "Merge pull request #3395 from bdurand/fix_file_store_cleanup"
Tests were failing on Travis-CI.

This reverts commit 79d01a8, reversing
changes made to b838570.

josevalim commented Oct 25, 2011

I had to revert this due to the failing tests.

@georgeG georgeG added a commit to georgeG/rails that referenced this pull request Oct 26, 2011

@georgeG georgeG Merge remote-tracking branch 'upstream/master'
* upstream/master: (91 commits)
  Responders now return 204 No Content for API requests without a response body (as in the new scaffold)
  Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box.
  Fix failing tests.
  properly handle lists of lists. Thanks @adrianpike for reporting!
  Fix that changing a store should mark the store attribute as changed
  Clean up .gitignore and make a note about using global ignores
  Revert "Ignore .rbx directories (rbx compiled bytecode files)"
  Revert "Merge pull request #3395 from bdurand/fix_file_store_cleanup"
  Fix deprecation warnings in action pack test suite due to passing template formats in the template name.
  safeguard against configs missing environment or the database key
  Remove needless to_param in scaffold functional test
  Unused variable removed
  minor revision to some new code in databases.rake
  registers PR #2419 in the CHANGELOG
  ActionPack test fix for RBX
  Ignore .rbx directories (rbx compiled bytecode files)
  edge doesnt provide turn gem in the gemfile anymore
  Remove Turn from default Gemfile.
  Revert "Merge pull request #3405 from arunagw/middleware_name"
  minor fixes in the composed_of doc


jrochkind commented Nov 9, 2012

hmm, i'm interested in this functionality. anyone know what the current status of this functionality is in master or 3-2-stable? Did it end up being fixed elsewhere? If not, anyone have any ideas as to what caused ci failure and blocked this? thanks for any info!

I'm using that methode: Rails.cache.cleanup(:expired_only => true) but after that i have empty directories. How can i remove the empty directories in the cache??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment