Method: IdentityCache::QueryAPI#_run_commit_callbacks

Defined in:
lib/identity_cache/query_api.rb

#_run_commit_callbacksObject

Override the method that is used to call after_commit callbacks so that we can expire the caches before other after_commit callbacks. This way we can avoid stale cache reads that happen from the ordering of callbacks. For example, if an after_commit callback enqueues a background job, then we don’t want it to be possible for the background job to run and load data from the cache before it is invalidated.



168
169
170
171
172
173
# File 'lib/identity_cache/query_api.rb', line 168

def _run_commit_callbacks
  if destroyed? || transaction_changed_attributes.present?
    expire_cache
  end
  super
end