Пример #1
0
    def test_clear_zeo_cache(self):
        cache = self.cache
        for i in range(10):
            cache.store(p64(i), n2, None, str(i).encode())
            cache.store(p64(i), n1, n2, str(i).encode()+b'old')
        self.assertEqual(len(cache), 20)
        self.assertEqual(cache.load(n3), (b'3', n2))
        self.assertEqual(cache.loadBefore(n3, n2), (b'3old', n1, n2))

        cache.clear()
        self.assertEqual(len(cache), 0)
        self.assertEqual(cache.load(n3), None)
        self.assertEqual(cache.loadBefore(n3, n2), None)
Пример #2
0
    def test_clear_zeo_cache(self):
        cache = self.cache
        for i in range(10):
            cache.store(p64(i), n2, None, str(i))
            cache.store(p64(i), n1, n2, str(i) + 'old')
        self.assertEqual(len(cache), 20)
        self.assertEqual(cache.load(n3), ('3', n2))
        self.assertEqual(cache.loadBefore(n3, n2), ('3old', n1, n2))

        cache.clear()
        self.assertEqual(len(cache), 0)
        self.assertEqual(cache.load(n3), None)
        self.assertEqual(cache.loadBefore(n3, n2), None)
Пример #3
0
 def testVeryLargeCaches(self):
     cache = ZEO.cache.ClientCache('cache', size=(1<<32)+(1<<20))
     cache.store(n1, n2, None, b"x")
     cache.close()
     cache = ZEO.cache.ClientCache('cache', size=(1<<33)+(1<<20))
     self.assertEquals(cache.load(n1), (b'x', n2))
     cache.close()
Пример #4
0
 def testVeryLargeCaches(self):
     cache = ZEO.cache.ClientCache('cache', size=(1 << 32) + (1 << 20))
     cache.store(n1, n2, None, "x")
     cache.close()
     cache = ZEO.cache.ClientCache('cache', size=(1 << 33) + (1 << 20))
     self.assertEquals(cache.load(n1), ('x', n2))
     cache.close()
Пример #5
0
    def testOldObjectLargerThanCache(self):
        if self.cache.path:
            os.remove(self.cache.path)
        cache = ZEO.cache.ClientCache(size=50)

        # We store an object that is a bit larger than the cache can handle.
        cache.store(n1, n2, n3, "x"*64)
        # We can see that it was not stored.
        self.assertEquals(None, cache.load(n1))
        # If an object cannot be stored in the cache, it must not be
        # recorded as non-current.
        self.assert_(1 not in cache.noncurrent)
Пример #6
0
    def testOldObjectLargerThanCache(self):
        if self.cache.path:
            os.remove(self.cache.path)
        cache = ZEO.cache.ClientCache(size=50)

        # We store an object that is a bit larger than the cache can handle.
        cache.store(n1, n2, n3, "x" * 64)
        # We can see that it was not stored.
        self.assertEquals(None, cache.load(n1))
        # If an object cannot be stored in the cache, it must not be
        # recorded as non-current.
        self.assert_(1 not in cache.noncurrent)