Skip to content

Commit

Permalink
Cron: remove Shrine cache items
Browse files Browse the repository at this point in the history
After cached items are promoted and file derivatives are produced, we have no need of them anymore. This rake task will run nightly to remove items a week old from our cache.

Fixes geobtaa/geoblacklight_admin#63
  • Loading branch information
ewlarson committed Jul 23, 2024
1 parent 5af4a0a commit cd0da2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
rake 'geoportal:sidecar_states'
end

# Clear S3 Cache - removes cached files older than 7 days
every :day, at: '8:00am', roles: [:app] do
rake 'geoportal:s3:clear_cache'
end

# URI analysis - No longer required - EWL 10/11/23
# every '0 1 1 * *', roles: [:prodcron] do
# rake 'geoportal:uri_purge'
Expand Down
8 changes: 8 additions & 0 deletions lib/tasks/geoportal/geoportal_s3.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace :geoportal do
namespace :s3 do
desc 'Clear S3 Cache'
task clear_cache: :environment do
Shrine.storages[:cache].clear! { |object| object.last_modified < Time.now - 7*24*60*60 }
end
end
end

0 comments on commit cd0da2b

Please sign in to comment.