def test_cache(self): self.assertIsNone(get_cache_version()) self.assertIsNone(get_cached_manifest()) set_cached_manifest("ciao") self.assertEqual(get_cache_version(), 1) self.assertEqual(get_cached_manifest(), "ciao") reset_cache_manifest() set_cached_value("nociao", 1) self.assertEqual(get_cached_manifest(), "ciao") self.assertEqual(get_cache_version(), 2)
def get_version_timestamp(self): """ Create the timestamp according to the current time. It tries to make it unique even for very short timeframes """ timestamp = get_cached_value("timestamp") if not timestamp: timestamp = int(time.time()*100)*10000 + datetime.utcnow().microsecond set_cached_value("timestamp", timestamp) return timestamp
def get_version_timestamp(self): """ Create the timestamp according to the current time. It tries to make it unique even for very short timeframes """ timestamp = get_cached_value("timestamp") if not timestamp: timestamp = int( time.time() * 100) * 10000 + datetime.utcnow().microsecond set_cached_value("timestamp", timestamp) return timestamp