def testCachingSmallDataInCompressedMemCache(self): """Tests if ``CompressedMemCache`` caches small data (1KB) successfully.""" self._MockPickleAndZlib() cache = caches.CompressedMemCache() data = 'A' * 1024 # A string of size 1KB. cache.Set('a', data) self.assertEquals(data, cache.Get('a'))
def testMissingSubPieceOfLargeDataInCompressedMemCache(self): """Tests ``CompressedMemCache`` returns None when the data is broken.""" self._MockPickleAndZlib() cache = caches.CompressedMemCache() data = 'A' * (1024 * 1024 * 2) # A string of size 2MB. cache.Set('a', data) memcache.delete('a-0') self.assertEquals(None, cache.Get('a'))
def testCachingLargeDataInCompressedMemCache(self): """Tests if LargData are cached successfully. App engine memcache can only cache data < 1MB at one time, so data > 1MB will be split into sub-piece and stored separately. """ self._MockPickleAndZlib() cache = caches.CompressedMemCache() data = 'A' * (1024 * 1024 * 2) # A string of size 2MB. cache.Set('a', data) self.assertEquals(data, cache.Get('a'))