Skip to content

Commit

Permalink
fixup! [Untested] Add expire_cache_for_{insert,update,delete} methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Jun 15, 2021
1 parent 27dac82 commit d96fc9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 0 additions & 11 deletions lib/identity_cache/parent_model_expiration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ def parent_expiration_entries
ParentModelExpiration.install_pending_parent_expiry_hooks(cached_model)
_parent_expiration_entries
end

def check_for_unsupported_parent_expiration_entries
return unless parent_expiration_entries.any?
msg = +"Unsupported manual expiration of #{name} record that is embedded in parent associations:\n"
parent_expiration_entries.each do |association_name, cached_associations|
cached_associations.each do |parent_class, _only_on_foreign_key_change|
msg << "- #{association_name}"
end
end
raise msg
end
end

included do
Expand Down
13 changes: 13 additions & 0 deletions lib/identity_cache/without_primary_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ def expire_cache_for_update(old_indexed_values, changes)
alias_method :expire_cache_for_insert, :expire_cache_for_insert_or_delete

alias_method :expire_cache_for_delete, :expire_cache_for_insert_or_delete

private

def check_for_unsupported_parent_expiration_entries
return unless parent_expiration_entries.any?
msg = +"Unsupported manual expiration of #{name} record that is embedded in parent associations:\n"
parent_expiration_entries.each do |association_name, cached_associations|
cached_associations.each do |parent_class, _only_on_foreign_key_change|
msg << "- #{association_name}"
end
end
raise msg
end
end
end
end

0 comments on commit d96fc9d

Please sign in to comment.