about summary refs log tree commit diff
path: root/app/models/account_domain_block.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-02-18 03:14:46 +0100
committerGitHub <noreply@github.com>2018-02-18 03:14:46 +0100
commitcba2897108dffe69d5a16befe6c6220f6eaae59f (patch)
treee247261ff56fa1751e914d650a4a4710c6417dd1 /app/models/account_domain_block.rb
parent9b8a4484778fb55bcb2526992807a51270229b72 (diff)
Cache relationships in API (#6482)
* Cache relationships in API

* Fetch relationships for search results in UI

* Only save one account's maps in each cache item
Diffstat (limited to 'app/models/account_domain_block.rb')
-rw-r--r--app/models/account_domain_block.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/account_domain_block.rb b/app/models/account_domain_block.rb
index abcc923b3..bc00b4f32 100644
--- a/app/models/account_domain_block.rb
+++ b/app/models/account_domain_block.rb
@@ -16,12 +16,16 @@ class AccountDomainBlock < ApplicationRecord
   belongs_to :account
   validates :domain, presence: true, uniqueness: { scope: :account_id }
 
-  after_create  :remove_blocking_cache
-  after_destroy :remove_blocking_cache
+  after_commit :remove_blocking_cache
+  after_commit :remove_relationship_cache
 
   private
 
   def remove_blocking_cache
     Rails.cache.delete("exclude_domains_for:#{account_id}")
   end
+
+  def remove_relationship_cache
+    Rails.cache.delete_matched("relationship:#{account_id}:*")
+  end
 end