diff options
-rw-r--r-- | app/models/custom_filter.rb | 12 | ||||
-rw-r--r-- | db/migrate/20191118102858_clear_filter_cache.rb | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index 28d413d9b..a90b99c48 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -18,16 +18,4 @@ class CustomFilter < ApplicationRecord belongs_to :account validates :phrase, presence: true - - after_commit :remove_cache - - private - - def remove_cache - Rails.cache.delete("filters:#{account_id}") - redis.del("custom_cw:#{account_id}") - redis.del("filtered_threads:#{account_id}") - redis.del("filtered_statuses:#{account_id}") - Redis.current.publish("timeline:#{account_id}", Oj.dump(event: :filters_changed)) - end end diff --git a/db/migrate/20191118102858_clear_filter_cache.rb b/db/migrate/20191118102858_clear_filter_cache.rb new file mode 100644 index 000000000..1c19f68d2 --- /dev/null +++ b/db/migrate/20191118102858_clear_filter_cache.rb @@ -0,0 +1,12 @@ +class ClearFilterCache < ActiveRecord::Migration[5.2] + include Redisable + + def change + ['custom_cw', 'filtered_threads', 'filtered_statuses'].each do |ns| + Rails.logger.info("Clearing keys matching '#{ns}:*' ...") + Rails.cache.delete_matched("#{ns}:*") + keys = redis.keys("#{ns}:*") + redis.del(*keys) unless keys.empty? + end + end +end |