[Zope3-checkins] CVS: Zope3/src/persistence - cache.py:1.5

Jeremy Hylton jeremy@zope.com
Tue, 11 Mar 2003 17:09:09 -0500


Update of /cvs-repository/Zope3/src/persistence
In directory cvs.zope.org:/tmp/cvs-serv21326

Modified Files:
	cache.py 
Log Message:
Must reverse() after sort(), because we want the biggest/oldest first.
Repair comment about relationship between _p_atime and now.


=== Zope3/src/persistence/cache.py 1.4 => 1.5 ===
--- Zope3/src/persistence/cache.py:1.4	Tue Mar 11 15:00:04 2003
+++ Zope3/src/persistence/cache.py	Tue Mar 11 17:09:06 2003
@@ -100,13 +100,17 @@
                 ob = ob()
             # The _p_atime field is seconds since the start of the day.
             # When we start a new day, we'll expect to see most of the
-            # _p_atime values be less than now.
+            # _p_atime values be greater than now.
             if ob._p_atime > now:
                 deltat = (86400 - ob._p_atime) + now
             else:
                 deltat = now - ob._p_atime
             L.append((deltat, oid, ob))
+
+        # Sort on deltat so that the least recently used objects --
+        # those with the largest deltat -- are at the front.
         L.sort()
+        L.reverse()
 
         if na > self._size:
             # If the cache is full, ghostify everything up to the cache