changeset 1632:f89736ab2c8e

ItemCache: CHANGES entry, epydoc comments
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 22 Oct 2006 00:29:13 +0200
parents 9f02d3c64f48
children c62b1d1961da
files MoinMoin/Page.py docs/CHANGES
diffstat 2 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sat Oct 21 04:37:50 2006 +0200
+++ b/MoinMoin/Page.py	Sun Oct 22 00:29:13 2006 +0200
@@ -27,6 +27,10 @@
         in and out.
     """
     def __init__(self, name):
+        """ Initialize ItemCache object.
+            @param name: name of the object, used for display in logging and
+                         influences behaviour of refresh().
+        """
         self.name = name
         self.cache = {}
         self.timestamp = None
@@ -35,14 +39,20 @@
 
     def putItem(self, request, name, key, data):
         """ Remembers some data for item name under a key.
-            request currently unused.
+            @param request: currently unused
+            @param name: name of the item (page), unicode
+            @param key: used as secondary access key after name
+            @param data: the data item that should be remembered
         """
         d = self.cache.setdefault(name, {})
         d[key] = data
 
     def getItem(self, request, name, key):
         """ Returns some item stored for item name under key.
-            Returns None, if there is no such item or key.
+            @param request: the request object
+            @param name: name of the item (page), unicode
+            @param key: used as secondary access key after name
+            @return: the data or None, if there is no such name or key.
         """
         self.refresh(request)
         try:
@@ -56,16 +66,17 @@
         logging.debug("%s cache %s (h/r %2.1f%%) for %r %r" % (
             self.name,
             hit_str,
-            float(self.hits*100)/self.requests,
+            float(self.hits * 100) / self.requests,
             name,
             key,
         ))
-        #if name == u"GermanDict": raise "DeBugging"
         return data
 
     def refresh(self, request):
-        """ Refresh the cache - if anything has changed in the wiki,
-            we see it in the edit-log.
+        """ Refresh the cache - if anything has changed in the wiki, we see it
+            in the edit-log and either delete cached data for the changed items
+            (for 'meta') or the complete cache ('pagelists').
+            @param request: the request object
         """
         from MoinMoin.logfile import editlog
         elog = editlog.EditLog(request)
--- a/docs/CHANGES	Sat Oct 21 04:37:50 2006 +0200
+++ b/docs/CHANGES	Sun Oct 22 00:29:13 2006 +0200
@@ -164,7 +164,9 @@
       NOTE: this is NOT in wikiconfig, but e.g. in moin.cgi or moin.py or ...
     * MOIN_DEBUG can be set in the environment to let MoinMoin ignore exceptions
       that would lead to a traceback in the browser. Thanks to Raphael Bossek.
-    
+    * There is a new MoinMoin.Page.ItemCache class now with automatic cache
+      invalidation based on global edit-log. We currently use it to cache page
+      acls, speedup Page.get_rev and reading the page local edit-log.
 
   New Features:
     * The standalone server script moved to the toplevel directory. This makes