Production usage of ActiveRecord::IdentityMap was short
I was thinking to try identity map in production. I had some negative feedback and actually comments on the net was not so positive. A lot of notes that its not production ready, because of association issues and so on. Here you can find more
But I want to speed up just read action While reading source code, I found that it has method :use which accepts block as parameter. So I’ve created around filter to use IdentityMap for particular action
around_filter :with_identity_map, :only => :index def with_identity_map ActiveRecord::IdentityMap.use do yield end end
Thats all. Results was positive. It decreased page load by two times from 1600 ms to 800ms. Which is still unacceptable. It looks like quick hack to fix not “perfect code”
Few weeks everything was ok. But after some changes IdentityMap starts conflicting with caching.
Errors was like “has_many association returns nil”. I disabled identity map. And then we refactored code as a result of refactorign page load downs to ~200 ms.
That was journey with identity_map.









