summaryrefslogtreecommitdiff
path: root/examples/dogpile_caching/helloworld.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dogpile_caching/helloworld.py')
-rw-r--r--examples/dogpile_caching/helloworld.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/examples/dogpile_caching/helloworld.py b/examples/dogpile_caching/helloworld.py
index 22d7f97be..0dbde5eaf 100644
--- a/examples/dogpile_caching/helloworld.py
+++ b/examples/dogpile_caching/helloworld.py
@@ -1,6 +1,4 @@
-"""helloworld.py
-
-Illustrate how to load some data, and cache the results.
+"""Illustrate how to load some data, and cache the results.
"""
@@ -24,9 +22,9 @@ people = Session.query(Person).options(FromCache("default")).all()
# 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()
+ options(FromCache("default")).\
+ filter(Person.name.between("person 02", "person 12")).\
+ all()
# the data is cached under string structure of the SQL statement, *plus*
# the bind parameters of the query. So this query, having
@@ -34,17 +32,17 @@ people_two_through_twelve = Session.query(Person).\
# previous one, issues new SQL...
print("loading people five through fifteen")
people_five_through_fifteen = Session.query(Person).\
- options(FromCache("default")).\
- filter(Person.name.between("person 05", "person 15")).\
- all()
+ options(FromCache("default")).\
+ filter(Person.name.between("person 05", "person 15")).\
+ all()
# ... but using the same params as are already cached, no SQL
print("loading people two through twelve...again!")
people_two_through_twelve = Session.query(Person).\
- options(FromCache("default")).\
- filter(Person.name.between("person 02", "person 12")).\
- all()
+ options(FromCache("default")).\
+ filter(Person.name.between("person 02", "person 12")).\
+ all()
# invalidate the cache for the three queries we've done. Recreate
@@ -54,9 +52,9 @@ people_two_through_twelve = Session.query(Person).\
print("invalidating everything")
Session.query(Person).options(FromCache("default")).invalidate()
Session.query(Person).\
- options(FromCache("default")).\
- filter(Person.name.between("person 02", "person 12")).invalidate()
+ options(FromCache("default")).\
+ filter(Person.name.between("person 02", "person 12")).invalidate()
Session.query(Person).\
- options(FromCache("default", "people_on_range")).\
- filter(Person.name.between("person 05", "person 15")).invalidate()
+ options(FromCache("default", "people_on_range")).\
+ filter(Person.name.between("person 05", "person 15")).invalidate()