mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
PERF: Add scheduled job to delete old stylesheet cache rows (#13747)
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user