IdentityMap feature for Active Record

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?

And the issue for this is on this link -…tail?id=2817#c0

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.

When we’ll show Yii2 code to community you’ll be able to test memory consumption to determine if it is necessary.

Yes, certainly. But this doesn’t really answer my question :rolleyes: I take it IMs are open for discussion again?

What’s “IMs”?

Identity Maps?

Yes, why not.

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.