3 ms·
I haven't had a lot of experience with caching, and I agree with your comment above about database views, but wouldn't the complications be mitigated by using t
by nfm 15y ago
I haven't had a lot of experience with caching, and I agree with your comment above about database views, but wouldn't the complications be mitigated by using the approach DHH detailed recently? http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works http://37signals.com/svn/posts/3113-how-key-based-cache-expi...
That is, incorporating `updated_at` into the cache key, and using `touch: true` on your AR relations to make sure that caches of affected parent objects get expired too?
Are there other complications I may not have run into yet?
- joevandyk 15y agoImagine you have User has_many Comments. When someone's username is updated, you might need to update all the user's cached html comment fragments to include the new username. However, ActiveRecord doesn't support touch on has_many relations. (It probably shouldn't, as updating the username would mean updating/touching thousands (or more) comment rows). Also, if you have to update the database outside of ActiveRecord for any reason, you could be screwed - the cache would become out of sync with the database.
- nfm 15y agoCheers, a helpful and extremely likely case!