-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Bayer wrote:
> 
> On Jan 25, 2014, at 11:48 AM, Jonathan Rogers <[email protected]> 
> wrote:
> 
>> I am experimenting with the caching example and have it working as
>> described. I have a number of mapped classes for tables which are static
>> lookup tables. The rows in the tables will not change during the
>> lifetime of application process. So, I would like to automatically apply
>> a FromCache option to any query which simply returns an instance of a
>> class mapped to one of the static lookup tables.
>>
>> It seems that I should be able to apply a FromCache option to any Query
>> which has only one entity which is one of the mapped classes I want to
>> cache. However, I'm not sure what interface to Query would allow me to
>> determine this. Has anyone solved a similar problem or have any
>> suggestions for where to start?
> 
> 
> when i used this I was able to apply a whole list of RelationshipCache 
> options to all queries, that option as written is suited to this since it 
> looks through query._current_path to identify first that it applies.
> 
Yeah, I had been thinking that maybe RelationshipCache was the way to
go. It hadn't occurred to me that I could apply the entire set of
RelationshipCache options to every Query. I have managed to inspect each
mapped class and generate a RelationshipCache for each of its
relationship attributes which points to a mapped class I want to cache
and apply all of them to each query.

> in the case of FromCache, the implementation in the example is more fixed, 
> but I would likely look into further altering CachingQuery.__iter__ to also 
> pull from a set of “fixed” cache options.   To see that a Query is against 
> “A” for a given “session.query(A)” you can look in query._entities for 
> exactly one entity which has “.mapper” set to the mapper you’re looking for.
> 

I think this shouldn't be necessary since I was able to generate
RelationshipCache instances. When I need to fetch instances of cacheable
classes directly, I can use custom methods which apply the appropriate
FromCache options. Also, I'm hesitant to use single underscore instance
attributes.

Thanks for the quick responses and excellent documentation!
- -- 
Jonathan Rogers
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlLkK5oACgkQVmXTv6uMqqPxSwCfYSo1iZ9DOiSS7ImzQ5cvzmUa
38oAoIfKvs+NEaOazGh74CvOivgUOXSX
=WbjJ
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to