this test raises assertion, tested on python2.6 python2.4 32-bin linux
without patch total_estimated_size is set to 0, and cache size is 1 (at this point cache is cleaned up on each collecting garbage)
with patch total_estimated_size is set to 320 and cache size is 2
def test_cache_garbage_collection_shrinking_object(self):
db = self.db
# activate size based cache garbage collection db.setCacheSizeBytes(1000)
obj, conn, cache = self.obj, self.conn, self.conn._cache
# verify the change worked as expected self.assertEqual(cache.cache_size_bytes, 1000)
# verify our entrance assumption is fullfilled self.assert_(cache.total_estimated_size > 1)
# give the objects some size obj.setValueWithSize(500) transaction.savepoint() self.assert_(cache.total_estimated_size > 500)
# make the object smaller obj.setValueWithSize(100) transaction.savepoint()
# make sure there was no overflow self.assert_(cache.total_estimated_size != 0)
this test raises assertion, tested on python2.6 python2.4 32-bin linux _size is set to 0, and cache size is 1 (at this point cache is cleaned up on each collecting garbage) _size is set to 320 and cache size is 2
without patch total_estimated
with patch total_estimated
def test_cache_ garbage_ collection_ shrinking_ object( self):
db.setCacheSiz eBytes( 1000)
self.assertEqu al(cache. cache_size_ bytes, 1000)
self.assert_ (cache. total_estimated _size > 1)
obj.setValueWi thSize( 500)
transaction. savepoint( )
self.assert_ (cache. total_estimated _size > 500)
obj.setValueWi thSize( 100)
transaction. savepoint( )
self.assert_ (cache. total_estimated _size != 0)
db = self.db
# activate size based cache garbage collection
obj, conn, cache = self.obj, self.conn, self.conn._cache
# verify the change worked as expected
# verify our entrance assumption is fullfilled
# give the objects some size
# make the object smaller
# make sure there was no overflow