about summary refs log tree commit diff
path: root/app/models/block.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-18 01:20:29 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-18 01:20:29 +0200
commit0e0347ea3c518e3e002a23ba84dc2f8ec4505984 (patch)
treea6ff64dec8a236a5d4807452f511379cf5d2d188 /app/models/block.rb
parentf03fb6c0aed5bdbe60a9f34c5de93865bf3e58eb (diff)
parentf5cd0b4956445d3e30d555a55d58fe8a04560632 (diff)
Merge branch 'pixiv-fix/cache_blocking'
Diffstat (limited to 'app/models/block.rb')
-rw-r--r--app/models/block.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/block.rb b/app/models/block.rb
index ae456a6b6..c978b2200 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -7,4 +7,14 @@ class Block < ApplicationRecord
   belongs_to :target_account, class_name: 'Account', required: true
 
   validates :account_id, uniqueness: { scope: :target_account_id }
+
+  after_create  :remove_blocking_cache
+  after_destroy :remove_blocking_cache
+
+  private
+
+  def remove_blocking_cache
+    Rails.cache.delete("exclude_account_ids_for:#{account_id}")
+    Rails.cache.delete("exclude_account_ids_for:#{target_account_id}")
+  end
 end