From b75630cec9418ef087e7c6af0370ac6ba728a251 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 5 Aug 2021 13:54:06 -0400 Subject: [PATCH] update local_session_caching.py example for 1.4 Fixes: #6858 Change-Id: I9b4113243f9ef32f27dcd1f7e9751923283eba2d --- examples/dogpile_caching/local_session_caching.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/dogpile_caching/local_session_caching.py b/examples/dogpile_caching/local_session_caching.py index 8f505ead72..e603cef642 100644 --- a/examples/dogpile_caching/local_session_caching.py +++ b/examples/dogpile_caching/local_session_caching.py @@ -13,6 +13,7 @@ with the basic operation of CachingQuery. from dogpile.cache.api import CacheBackend from dogpile.cache.api import NO_VALUE from dogpile.cache.region import register_backend +from examples.dogpile_caching import environment class ScopedSessionBackend(CacheBackend): @@ -76,7 +77,7 @@ if __name__ == "__main__": q = ( Session.query(Person) .filter(Person.name == "person 10") - .execution_options(cache_options=FromCache("local_session")) + .options(FromCache("local_session")) ) # load from DB @@ -99,5 +100,8 @@ if __name__ == "__main__": # that would change the results of a cached query, such as # inserts, deletes, or modification to attributes that are # part of query criterion, still require careful invalidation. - cache, key = q._get_cache_plus_key() - assert person10 is cache.get(key)[0] + cache_key = FromCache("local_session")._generate_cache_key( + q._statement_20(), {}, environment.cache + ) + + assert person10 is regions["local_session"].get(cache_key)().scalar() -- 2.47.2