diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-21 20:10:23 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-21 20:10:23 -0500 |
commit | 07fb90c6cc14de6d02cf4be592c57d56831f59f7 (patch) | |
tree | 050ef65db988559c60f7aa40f2d0bfe24947e548 /examples/dogpile_caching/helloworld.py | |
parent | 560fd1d5ed643a1b0f95296f3b840c1963bbe67f (diff) | |
parent | ee1f4d21037690ad996c5eacf7e1200e92f2fbaa (diff) | |
download | sqlalchemy-ticket_2501.tar.gz |
Merge branch 'master' into ticket_2501ticket_2501
Conflicts:
lib/sqlalchemy/orm/mapper.py
Diffstat (limited to 'examples/dogpile_caching/helloworld.py')
-rw-r--r-- | examples/dogpile_caching/helloworld.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/dogpile_caching/helloworld.py b/examples/dogpile_caching/helloworld.py index 4561097b6..22d7f97be 100644 --- a/examples/dogpile_caching/helloworld.py +++ b/examples/dogpile_caching/helloworld.py @@ -8,27 +8,27 @@ from .environment import Session from .model import Person from .caching_query import FromCache -# load Person objects. cache the result under the namespace "all_people". +# load Person objects. cache the result in the "default" cache region print("loading people....") people = Session.query(Person).options(FromCache("default")).all() # remove the Session. next query starts from scratch. Session.remove() -# load again, using the same FromCache option. now they're cached -# under "all_people", no SQL is emitted. +# load again, using the same FromCache option. now they're cached, +# so no SQL is emitted. print("loading people....again!") people = Session.query(Person).options(FromCache("default")).all() -# want to load on some different kind of query ? change the namespace -# you send to FromCache +# Specifying a different query produces a different cache key, so +# these results are independently cached. print("loading people two through twelve") people_two_through_twelve = Session.query(Person).\ options(FromCache("default")).\ filter(Person.name.between("person 02", "person 12")).\ all() -# the data is cached under the "namespace" you send to FromCache, *plus* +# the data is cached under string structure of the SQL statement, *plus* # the bind parameters of the query. So this query, having # different literal parameters under "Person.name.between()" than the # previous one, issues new SQL... |