the RelationshipCache idea doesn't have an "invalidate" approach that is 
straightforward to use right now.   The recipe below will do it, and at the 
very least you could create an "invalidate()" function that receives the 
arguments "Office", "by_id", 197 and does what you have below.

Otherwise I would suggest building an additional system into the 
RelationshipCache object that generates cache keys in a more deliberate way, 
and provides an API to send an "invalidation" instruction which also generates 
that same key (this would involve rewriting _get_cache_parameters to work more 
from the perspective of the RelationshipCache object, rather than just the 
Query).

Also, this print statement added to _get_cache_parameters should illustrate 
what namespaces/keys are being generated.   The scheme to generate a 
namespace/key can be whatever you want it to be.

    print "CACHE NAMESPACE", namespace, "REGION", region, "KEY", cache_key



On Jul 5, 2010, at 7:33 AM, sector119 wrote:

> I was wrong. This works, but it's not handy to recreate query manually
> that was generated by by SA  (it's lazy relation) :(
> 
> Maybe it's possible to do that another way?
> 
> q = meta.Session.query(Office).\
>                           options(cache.FromCache('default',
> 'by_id')).\
>                           filter_by(id=197)
> q.invalidate()
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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