you'd like to do query caching.   If it were me, I'd implement this at  
the SQL level by intercepting statements for particular tables, and  
matching the criteria to a cached value.   Inspection of the criteria  
would determine if it was a candidate for caching or not (or you could  
pre-populate the cache through some other means).  But in that case  
you'd have a lot of work to do, building a ResultProxy-like object and  
such, and the mappers would still need to generate object instances  
from results.   The easiest hook we have for this is in 0.5 and is  
called ConnectionProxy.

The MapperExtension has some sort-of paths for implementing caching  
but they are not widely used and don't really cover the  
functionality.  You can instead produce your own subclass of Query  
which overrides everything needed.  The Session.query() method  
ultimately uses an attribute "_query_cls" to generate Query so you  
could feed it in through a quick subclass of Session  (the shard.py  
example uses this approach).


On May 28, 2008, at 7:55 AM, Koen Bok wrote:

>
> Hey All,
>
> I have a conceptual question.
>
> You have two ways to get relations; lazy and nonlazy. Nonlazy works
> great for saving queries but can get pretty slow with complicated
> joins. So I was wondering if there was a third way; pre fetching all
> the data for relations and let the mapper get the relation data from a
> cache instead of doing another query.
>
> It's kinda hard to explain, so I wrote an example script at:
> http://paste.pocoo.org/show/55145/
>
> I guess this should be possible by writing some MapperExtension? Did
> anyone do anything like this, or maybe has some pointers?
>
> Thanks!
>
> Koen
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to