{"id":31009352,"url":"https://github.com/robhurring/timed_file_store","last_synced_at":"2025-09-13T04:34:27.683Z","repository":{"id":484602,"uuid":"110464","full_name":"robhurring/timed_file_store","owner":"robhurring","description":"Rails cache file store with timed expirations built in (simple method)","archived":false,"fork":false,"pushed_at":"2009-01-19T16:19:57.000Z","size":80,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-13T19:19:39.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robhurring.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-01-19T15:05:58.000Z","updated_at":"2019-08-13T13:54:42.000Z","dependencies_parsed_at":"2022-07-14T14:31:19.821Z","dependency_job_id":null,"html_url":"https://github.com/robhurring/timed_file_store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robhurring/timed_file_store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Ftimed_file_store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Ftimed_file_store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Ftimed_file_store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Ftimed_file_store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robhurring","download_url":"https://codeload.github.com/robhurring/timed_file_store/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robhurring%2Ftimed_file_store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274919745,"owners_count":25373953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-13T04:34:26.391Z","updated_at":"2025-09-13T04:34:27.667Z","avatar_url":"https://github.com/robhurring.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"==About\n\nThis is just a subclass of the default FileStore caching option but with a few methods overridden to allow\nyou to expire the cache. It is extremely basic, but was necessary for my project so I'll release it into the\nwild. Keep in mind that this hasn't been heavily tested and there are some quirks. But what do you expect from\na quick-and-dirty hack? :)\n\nMore on this: http://blog.ubrio.us/ruby/ruby-rails/simple-rails-time-based-fragment-caching-with-file-store/\n\n==Features\n\n# Can expire from the controller or view\n# Super lightweight\n# No modification necessary if you are already using FileStore\n# Expires caches automatically\n\n==Setup\n\nIn your +environment.rb+ file just set the cache_store to :timed_file_store\n\tconfig.cache_store = :timed_file_store, File.join(RAILS_ROOT, 'tmp', 'cache')\n\n==Usage\n\n===Expiring Cache From the Controller\n\nHaving the controller control the expiration of the cache is good if you are passing along any objects to the \nviews since it will not re-run the code if it is already cached. \n\n\n\t# reports_controller\n\t# reports/1\n\t@report = Report.find(params[:id])\n\tunless fragment_exists?(\"report_#{@report.id}\", :time_to_live =\u003e 1.week)\n\t  @report.run!\n\tend\n\n\t# views/reports/show.html.erb -- or whatever view file\n\t\u003c% cache(\"report_#{@report.id}\") do -%\u003e;\n\t  \u003c!-- output the report HTML and such --\u003e\n\t\t\u003c%= @report.name %\u003e\n\t\u003c% end -%\u003e;\n\n===Expiring Cache From the View\n\nIf you aren't running any intense code in the controller and just want to keep a certain view fragment \ncached for a while, this should work. (** I didn't test this since I only needed the previous method, but it should work -- maybe with some slight tweaks? :)\n\n\t# views/wherever/whatever.html.erb\n\t\u003c% cache(\"whatever\", :time_to_live =\u003e 1.hour) do -%\u003e;\n\t  \u003c!-- This is my HTML content and all that jazz --\u003e\n\t  \u003c!-- After 1 hour this cache should be re-freshed --\u003e\n\t\u003c% end -\u0026\u003e;\n\nNot sure how useful that would be when considering action and page caching... but its possible. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhurring%2Ftimed_file_store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobhurring%2Ftimed_file_store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobhurring%2Ftimed_file_store/lists"}