changeset 681:2d5883e4b82c

scope == {'item', 'wiki', 'farm'} for caching
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 May 2006 18:01:23 +0200
parents d6556513c4d3
children 1314fdb74689
files MoinMoin/caching.py docs/CHANGES
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/caching.py	Sun May 21 16:54:45 2006 +0200
+++ b/MoinMoin/caching.py	Sun May 21 18:01:23 2006 +0200
@@ -21,6 +21,10 @@
             @param arena: either a string or a page object, when we want to use
                           page local cache area
             @param key: under which key we access the cache content
+            @param scope: the scope where we are caching:
+                          'item' - an item local cache
+                          'wiki' - a wiki local cache
+                          'farm' - a cache for the whole farm
         """
         self.request = request
         if scope == 'page_or_wiki': # XXX split and refactor later
@@ -29,6 +33,12 @@
                 filesys.makeDirs(self.arena_dir)
             else: # arena is in fact a page object
                 self.arena_dir = arena.getPagePath('cache', check_create=1)
+        elif scope == 'item': # arena is a Page instance
+            # we could move cache out of the page directory and store it to cache_dir
+            self.arena_dir = arena.getPagePath('cache', check_create=1)
+        elif scope == 'wiki':
+            self.arena_dir = os.path.join(request.cfg.cache_dir, request.cfg.siteid, arena)
+            filesys.makeDirs(self.arena_dir)
         elif scope == 'farm':
             self.arena_dir = os.path.join(request.cfg.cache_dir, '__common__', arena)
             filesys.makeDirs(self.arena_dir)
--- a/docs/CHANGES	Sun May 21 16:54:45 2006 +0200
+++ b/docs/CHANGES	Sun May 21 18:01:23 2006 +0200
@@ -63,7 +63,9 @@
     * Added thread_monitor. It can be activated using:
       from MoinMoin.util import thread_monitor; thread_monitor.activate_hook()
     * Introduced scope parameter to CacheEntry() - if you specify 'farm', it
-      will cache into a common directory for all wikis in the same farm.
+      will cache into a common directory for all wikis in the same farm, if you
+      specify 'wiki', it will use a cache directory per wiki and if you specify
+      'item', it will use a cache directory per item (== per page).
 
   New Features: