Skip to content

Commit

Permalink
Rename methods to avoid confusion for new manual expiration methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Jun 15, 2021
1 parent 771b0f9 commit c5038e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/identity_cache/cached/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def fetch(db_key)
end
end

def expire(record)
def expire_for_save(record)
unless record.send(:was_new_record?)
old_key = old_cache_key(record)
old_key = old_cache_key_for_record(record)
IdentityCache.cache.delete(old_key)
end
unless record.destroyed?
new_key = new_cache_key(record)
new_key = new_cache_key_for_record(record)
if new_key != old_key
IdentityCache.cache.delete(new_key)
end
Expand Down Expand Up @@ -95,12 +95,12 @@ def cache_key_prefix
end
end

def new_cache_key(record)
def new_cache_key_for_record(record)
new_key_values = key_fields.map { |field| record.send(field) }
cache_key_from_key_values(new_key_values)
end

def old_cache_key(record)
def old_cache_key_for_record(record)
old_key_values = key_fields.map do |field|
field_string = field.to_s
changes = record.transaction_changed_attributes
Expand Down
2 changes: 1 addition & 1 deletion lib/identity_cache/query_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def was_new_record? # :nodoc:

def expire_attribute_indexes # :nodoc:
cache_indexes.each do |cached_attribute|
cached_attribute.expire(self)
cached_attribute.expire_for_save(self)
end
end
end
Expand Down

0 comments on commit c5038e5

Please sign in to comment.