PERF: Add scheduled job to delete old stylesheet cache rows (#13747)

This commit is contained in:
Penar Musaraj
2021-07-16 10:58:01 -04:00
committed by GitHub
parent 810892139b
commit 361c8be547
3 changed files with 37 additions and 1 deletions

View File

@ -4,6 +4,7 @@ class StylesheetCache < ActiveRecord::Base
self.table_name = 'stylesheet_cache'
MAX_TO_KEEP = 50
CLEANUP_AFTER_DAYS = 150
def self.add(target, digest, content, source_map, max_to_keep: nil)
max_to_keep ||= MAX_TO_KEEP
@ -42,6 +43,10 @@ class StylesheetCache < ActiveRecord::Base
end
end
def self.clean_up
StylesheetCache.where('created_at < ?', CLEANUP_AFTER_DAYS.days.ago).delete_all
end
end
# == Schema Information