diff options
Diffstat (limited to 'examples/beaker_caching/advanced.py')
| -rw-r--r-- | examples/beaker_caching/advanced.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/beaker_caching/advanced.py b/examples/beaker_caching/advanced.py index 113060033..c16e02f33 100644 --- a/examples/beaker_caching/advanced.py +++ b/examples/beaker_caching/advanced.py @@ -13,13 +13,13 @@ from sqlalchemy.orm import joinedload def load_name_range(start, end, invalidate=False): """Load Person objects on a range of names. - + start/end are integers, range is then "person <start>" - "person <end>". - + The cache option we set up is called "name_range", indicating a range of names for the Person class. - + The `Person.addresses` collections are also cached. Its basically another level of tuning here, as that particular cache option can be transparently replaced with joinedload(Person.addresses). @@ -36,17 +36,17 @@ def load_name_range(start, end, invalidate=False): # have the "addresses" collection cached separately # each lazyload of Person.addresses loads from cache. q = q.options(RelationshipCache("default", "by_person", Person.addresses)) - + # alternatively, eagerly load the "addresses" collection, so that they'd # be cached together. This issues a bigger SQL statement and caches # a single, larger value in the cache per person rather than two # separate ones. #q = q.options(joinedload(Person.addresses)) - + # if requested, invalidate the cache on current criterion. if invalidate: q.invalidate() - + return q.all() print "two through twelve, possibly from cache:\n" |
