about summary refs log tree commit diff
path: root/app/models/concerns/relationship_cacheable.rb
blob: 0d9359f7e7b71a971ae725c78d7bee71d6786faa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module RelationshipCacheable
  extend ActiveSupport::Concern

  included do
    after_commit :remove_relationship_cache
  end

  private

  def remove_relationship_cache
    Rails.cache.delete("relationship:#{account_id}:#{target_account_id}")
    Rails.cache.delete("relationship:#{target_account_id}:#{account_id}")
  end
end