From e104dfff86f03b440e4fe1f48022d2d4ac18ebce Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 25 Aug 2010 11:00:35 -0400 Subject: [PATCH] add a note --- examples/beaker_caching/caching_query.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/beaker_caching/caching_query.py b/examples/beaker_caching/caching_query.py index 0b2238282d..a94eea6ac2 100644 --- a/examples/beaker_caching/caching_query.py +++ b/examples/beaker_caching/caching_query.py @@ -62,6 +62,14 @@ class CachingQuery(Query): """override __iter__ to pull results from Beaker if particular attributes have been configured. + Note that this approach does *not* detach the loaded objects from + the current session. If the cache backend is an in-process cache + (like "memory") and lives beyond the scope of the current session's + transaction, those objects may be expired. The method here can be + modified to first expunge() each loaded item from the current + session before returning the list of items, so that the items + in the cache are not the same ones in the current Session. + """ if hasattr(self, '_cache_parameters'): return self.get_value(createfunc=lambda: list(Query.__iter__(self))) -- 2.47.2