views:

91

answers:

1

We have our ORM pretty nicely coupled with cache, so all our object gets are cached. Currently we invalidate our objects before and after our insert/update/delete of our object. What's your experience?

A: 

Why before AND after i/u/d?

If you don't want to update your cache directly then it's enough to invalidate an object after i/u/d assuming you load it into cache on every cache miss. If your object space is big enough that your cache could use up too much memory, you'll need some expiration mechanism too (invalidate after X minutes or after X minutes w/o being accessed).

Or you could go for LRU (Least Recently used) but this is not easy to implement on your own if your ORM doesn't support it natively.

Manu