Rails has recently introduced an identity map feature that ensures that models are loaded only once in a request. This is really useful to maintain consistency, it means you never get multiple instances of the same model floating around in the same request, so it can save a lot of resources if used properly.
I’ve added a quick implementation here:
It’d be really nice to have this in the core (although it should be disabled by default). I already opened a feature request for it, but I don’t think Qiang sees the advantages of it yet. Does anyone else have any thoughts on the matter?
Is there any chance this is going to be reconsidered for Yii 2.0? A similar issue has been closed, stating that Yii now supports query caching. But I think query caching solves other problems than an identity map does.
I don’t think the biggest advantage of IM’s are memory onces.
It’s the fact that you could be overwriting yourself several times in an app and that this could be a “very hard to debug”-bug that happens occasionally and you might never know about it.