Hi, I am trying to use the query caching solution described here: http://svn.sqlalchemy.org/sqlalchemy/trunk/examples/query_caching/per_session.py
In most cases it works, the returned records are cached, I store them in a LRU cache modeled after http://code.activestate.com/recipes/498245/ However, when I run a long running operation, which operates on hundreds of other records, apparently the garbage collection is run on the session's weak-referencing identity map. The cache keeps the returned records, but other eagerly loaded related instances of the returned records are lost. The ORM issues queries to load them again from the database. I understand that there are no strong references between an instance and other related instances. What is the best solution to keep related instances in a session? If I create a session with weak_identity_map=False, then during my long running operation I will run out of memory, unless I expunge unused records, however, it is easy to miss one record and the identity map will be growing anyway. Is there possible to get a list of referenced instances of another instance, so that I could store the list together with the instance in the MRU cache? Or to make a session with a strong-referencing map and LRU policy that keeps it below a given size? Regards, Adam --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---