def prepareCachingTransaction(): if cached_list.isCachedListExists(data_id): if cached_list.isProcessing(data_id): return False else: cached_list.setProcessing(data_id) return True else: cached_list.createEmptyProcessingList(data_id) return True
def getListData(self, list_id, query, start=None, limit=50): """See ListDataReader.getListData for specification.""" data_id = getDataId(query) if cached_list.isCachedListExists(data_id): if cached_list.isValid(data_id): return ListData(cached_list.getCachedItems(data_id), FINAL_BATCH) else: if not cached_list.isProcessing(data_id): self._start_caching(list_id, data_id, query) # return None because cache is not hit return None else: self._start_caching(list_id, data_id, query) # return None because cache is not hit return None
def testForExistence(self): """Test whether True is returned only when the list exists.""" self.assertTrue(cached_list_logic.isCachedListExists('cached_list')) self.assertFalse(cached_list_logic.isCachedListExists('none_existent'))