Thread Previous • Date Previous • Date Next • Thread Next |
On 2010-08-13 05:02, Robert Collins wrote:
Ugh; well I can see that being a risk too. OTOH we have no way to represent many of our derived data except via caching (cachedproperty or otherwise).
I see another risk as well: is __storm_invalidated__ good enough? If a @cachedproperty involves data that's one or more joins away, who says that __storm_invalidated__ will ever be invoked before you re-use stale data?
A safer approach that I've seen, though less aggressive and less convenient, is to adapt-and-delegate. It feels a lot like caching in browser code. Say Foo implements IFoo. You load up a Foo from the database, but adapt it to ICachingFoo. That gives you an object that delegates IFoo to the real Foo, but adds all sorts of caching. The model object stays cached as aggressively as the ORM can manage, but the object's caches are gone when you finish with the request.
Jeroen
Thread Previous • Date Previous • Date Next • Thread Next |