wheezy.web / doc / tutorial.rst

Diff from to

File doc/tutorial.rst

 and regenerate only when someone added another greeting? Let implement
 this use case with `wheezy.caching`_ package.
-Open ```` and add import for MemoryCache::
+Open ```` and add import for MemoryCache and Cached::
     from wheezy.caching.memory import MemoryCache
 and configuration options for HTTP cache middleware)::
     cache = MemoryCache()
+    cached = Cached(cache, time=15 * 60)
     # HTTPCacheMiddleware
 Let add cache invalidation logic so once user enters a new greeting it cause
 the list page to be refreshed.
-In file ```` add import for ``CacheDependency``::
+In file ```` add import for ``Cached``::
-    from wheezy.caching import CacheDependency
+    from wheezy.caching.patterns import Cached
-Declare cache dependency (right after all imports)::
+Declare cached (right after created cache instance)::
-    list_cache_dependency = CacheDependency('list', time=15 * 60)
+    cache = MemoryCache()
+    cached = Cached(cache, time=15 * 60)
-Modify ``ListHandler`` so it is aware about the list cache dependency::
+Modify ``ListHandler`` so it is aware about the list cache dependency key::
     class ListHandler(BaseHandler):
                 greetings = repo.list_greetings()
             response = self.render_response('list.html',
-            response.dependency = list_cache_dependency
+            response.dependency_key = 'd_list'
             return response
 Finally let add a trigger that cause the invalidation to occur in cache.
-Import cache factory from config module::
+Import cached from config module::
-    from config import cache
+    from config import cached
 Modify ``AddHandler`` so on successful commit the content cache for
 ``ListHandler`` response is invalidated::
         def post(self):
-            list_cache_dependency.delete(cache)
+            cached.dependency.delete('d_list')
             return self.see_other_for('list')
 Try run application by issuing the following command::