示例#1
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)
示例#2
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)
示例#3
0
    def test_loadBefore_doesnt_miss_current(self):
        # Make sure that loadBefore get's current data if there
        # isn't non-current data

        cache = self.cache
        oid = n1
        cache.store(oid, n1, None, b'first')
        self.assertEqual(cache.loadBefore(oid, n1), None)
        self.assertEqual(cache.loadBefore(oid, n2), (b'first', n1, None))
        self.cache.invalidate(oid, n2)
        cache.store(oid, n2, None, b'second')
        self.assertEqual(cache.loadBefore(oid, n1), None)
        self.assertEqual(cache.loadBefore(oid, n2), (b'first', n1, n2))
        self.assertEqual(cache.loadBefore(oid, n3), (b'second', n2, None))
示例#4
0
    def test_loadBefore_doesnt_miss_current(self):
        # Make sure that loadBefore get's current data if there
        # isn't non-current data

        cache = self.cache
        oid = n1
        cache.store(oid, n1, None, b'first')
        self.assertEqual(cache.loadBefore(oid, n1), None)
        self.assertEqual(cache.loadBefore(oid, n2), (b'first', n1, None))
        self.cache.invalidate(oid, n2)
        cache.store(oid, n2, None, b'second')
        self.assertEqual(cache.loadBefore(oid, n1), None)
        self.assertEqual(cache.loadBefore(oid, n2), (b'first', n1, n2))
        self.assertEqual(cache.loadBefore(oid, n3), (b'second', n2, None))