Re: [sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread Michael Bayer
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

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
And one more question about caching, how can I invalidate all cached queries for User model? For one user I make: q = meta.Session.query(User).\ options(cache_user_relationships).\ options(cache.FromCache('default', 'by_username')).\ filter_by(use

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
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')).\

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
Is it have sense to have something like RelationFromCache(region, namespace, attribute) ? To use it like: meta.Session.query(User).\ options(cache.RelationFromCache('default', 'by_id', User.office)).\ filter_by(username=username, disabled=False).\

[sqlalchemy] Re: How to invalidate RelationshipCache?

2010-07-05 Thread sector119
> cache_user_relationships = cache.RelationshipCache('default', 'by_id', > User.locality).and_( >                            cache.RelationshipCache('default', 'by_id', > User.office)).and_( >                            cache.RelationshipCache('default', 'by_id', > User.groups)).and_( >