def test_cachedb_stress(): disk = PersistentNetworkCache() disk.clean(audit) try: print "Stress testing the disk cache..." helper_cachedb_stress(disk, 10) helper_cachedb_stress(disk, 20) helper_cachedb_stress(disk, 30) helper_cachedb_stress(disk, 100) finally: print "Cleaning up the disk cache..." try: disk.clean(audit) finally: disk.close()
def test_cachedb_consistency(): mem = VolatileNetworkCache() disk = PersistentNetworkCache() disk.clean(audit) try: print "Testing consistency of in-memory and disk caches..." for x in xrange(100): key = generate_random_string(10) data = generate_random_string(100) helper_test_cachedb_consistency(mem, key, data) helper_test_cachedb_consistency(disk, key, data) print "Testing disk cache compacting and dumping..." disk.compact() disk.dump("test_cachedb.sql") print "Cleaning up the memory cache..." mem.clean(audit) del mem finally: print "Cleaning up the disk cache..." try: disk.clean(audit) finally: disk.close()