Re: loading many objects from one query

[prev] [thread] [next] [Date index for 2004/09/14]

From: Todd Lorenz
Subject: Re: loading many objects from one query
Date: 16:13 on 14 Sep 2004
Wondering...

Why not go ahead and start thinking about the possibility of officially 
changing the status of the object index to object cache? Though the purpose 
of the index may be to prevent duplicate objects in memory, this does 
currently have the side effect of acting as a cache in some cases. It seems 
as though most people are thinking of the index in terms of a cache already, 
anyway. If I understand it correctly (which I'm not sure I do) the only 
difference would be that the object wouldn't be blown away in the 
index/cache when all other references to it go out of scope. (Perhaps the 
weakref functionality could be retained, but made optional.)

With a few fairly straightforward changes to CDBI to make the index/cache 
the first stop on the way to the DB in *all* cases where an id-based lookup 
is performed (this could include has_many and might_have), CDBI might pick 
up a lot of extra utility. (Caching wishes aside, it might be a win if only 
because things like retrieve() and has_a would be performing their lookups 
in a consistent manner.)

Todd Lorenz

>Tim Bunce wrote:
>>>The tricky part would be making the relationship accessors use an 
>>>in-memory cache instead of the database.  I would suggest doing that part 
>>>by writing your own relationship type that looks at a cache first and 
>>>then calls the normal has_many relationship code if it doesn't find 
>>>anything.
>>
>>
>>Umm. Seems like a bug/limitation of the caching code that construct() 
>>isn't
>>integrated with it in some way. Currently all uses of sth_to_objects()
>>don't consider the cache at all.
>
>That's because there is no cache. :)
>
>The existing object index is only intended to avoid having duplicates of 
>the same object in memory.  Caching relationships and avoiding database 
>hits is outside of that.
>
>- Perrin


(message missing)

loading many objects from one query
Andrew Pimlott 01:05 on 14 Sep 2004

Re: loading many objects from one query
Perrin Harkins 02:22 on 14 Sep 2004

Re: loading many objects from one query
Tim Bunce 09:09 on 14 Sep 2004

Re: loading many objects from one query
Perrin Harkins 14:21 on 14 Sep 2004

Re: loading many objects from one query
Tim Bunce 16:07 on 14 Sep 2004

Re: loading many objects from one query
Perrin Harkins 16:12 on 14 Sep 2004

Re: loading many objects from one query
Andrew Pimlott 23:05 on 14 Sep 2004

Re: loading many objects from one query
Perrin Harkins 23:22 on 14 Sep 2004

Re: loading many objects from one query
Todd Lorenz 16:13 on 14 Sep 2004

Re: loading many objects from one query
Tim Bunce 13:52 on 15 Sep 2004

Re: loading many objects from one query
Perrin Harkins 15:22 on 15 Sep 2004

Re: loading many objects from one query
merlyn (Randal L. Schwartz) 17:10 on 16 Sep 2004

Re: loading many objects from one query
Andrew Pimlott 19:17 on 16 Sep 2004

Re: loading many objects from one query
Tim Bunce 17:36 on 14 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52