[Zodb-checkins] CVS: ZODB3/ZEO/tests - test_cache.py:1.1.2.10

Jeremy Hylton jeremy at zope.com
Tue Dec 23 00:03:06 EST 2003


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv23095/ZEO/tests

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	test_cache.py 
Log Message:
A persistent cache file based on the internal "dcache."

A single file with a currentofs pointer that goes around the file,
circularly, forever.  Whenever a new object is added to the cache, we
evict objects starting at currentofs until space is available for the
new object.  This variant of dcache doesn't have any copying.

The separation between the upper ClientCache and the lower FileCache
is imperfect, but perhaps helpful.


=== ZODB3/ZEO/tests/test_cache.py 1.1.2.9 => 1.1.2.10 ===
--- ZODB3/ZEO/tests/test_cache.py:1.1.2.9	Tue Dec  2 02:10:30 2003
+++ ZODB3/ZEO/tests/test_cache.py	Tue Dec 23 00:03:03 2003
@@ -30,6 +30,7 @@
 
     def setUp(self):
         self.cache = ZEO.cache.ClientCache()
+        self.cache.open()
 
     def tearDown(self):
         if self.cache.path:
@@ -103,7 +104,8 @@
 
     def testEviction(self):
         # Manually override the current maxsize
-        maxsize = self.cache.size = self.cache.dll.maxsize = 1245
+        maxsize = self.cache.size = self.cache.dll.maxsize = 3395 # 1245
+        self.cache.dll = ZEO.cache.Cache(3395, None, self.cache)
 
         # Trivial test of eviction code.  Doesn't test non-current
         # eviction.
@@ -128,10 +130,16 @@
         self.cache.store(n2, "version", n2, None, "version data for n2")
         self.cache.store(n3, "", n3, n4, "non-current data for n3")
         self.cache.store(n3, "", n4, n5, "more non-current data for n3")
-        self.cache.path = tempfile.mktemp()
-        self.cache._write()
-
-        copy = ZEO.cache.ClientCache(self.cache.path)
+        
+        path = tempfile.mktemp()
+        # Copy data from self.cache into path, reaching into the cache
+        # guts to make the copy.
+        dst = open(path, "wb+")
+        src = self.cache.dll.f
+        src.seek(0)
+        dst.write(src.read(self.cache.dll.maxsize))
+        dst.close()
+        copy = ZEO.cache.ClientCache(path)
         copy.open()
 
         # Verify that internals of both objects are the same.




More information about the Zodb-checkins mailing list