Shopify/identity_cache — pull request #193 by dylanahsmith (2014-12-22 07:55:29+00:00)
Title: Allow cache invalidation in transactions again.

@fbogsany & @arthurnn for review
cc @jstorimer

## Problem

IDC v0.2.2 has a regression where touching a record no longer invalidates the cache for that record. This was because the record was being invalidated in an after_touch callback, where `IdentityCache.should_update_cache?` returned falsey, since `IdentityCache.should_update_cache?` returns falsey.

## Solution

Ideally we would always invalidate the cache in an after_commit callback, but invalidating the cache should always be a safe thing to do, even inside a transaction.

The actual concern in updating the cache with `IdentityCache.readonly = true` in our use case was database slave lag, where is it safe to fetch from the cache, but unsafe to fill the cache, since it could fill the cache with stale data. Therefore, I renamed `should_update_cache?` to `should_fill_cache?` and had it stop requiring `should_use_cache?` to return truthy.