def test_get_exists(self): """Test that the value is returned if a key has been saved.""" CacheService.set_value_for_key('fake_key', 'fake_value') self.assertEquals( CacheService.fetch_value_for_key('fake_key'), 'fake_value', )
def test_get_exists(self): """Test that the value is returned if a key has been saved.""" CacheService.set_value_for_key('fake_key', 'fake_value') self.assertEquals( CacheService.fetch_value_for_key('fake_key'), 'fake_value', )
def _mark_hash_seen(self, data_hash): """Adds the data hash to the cache. :param str data_hash: hash to store """ CacheService.set_value_for_key( self._get_cache_key(data_hash), data_hash, )
def _mark_hash_seen(self, data_hash): """Adds the data hash to the cache. :param str data_hash: hash to store """ CacheService.set_value_for_key( self._get_cache_key(data_hash), data_hash, )
def test_ttl(self): """Test that a key can expire.""" with freeze_time('2014-01-01T00:00:00'): CacheService.set_value_for_key('fake_key', 'fake_value', ttl=5) self.assertEquals( CacheService.fetch_value_for_key('fake_key'), 'fake_value', ) with freeze_time('2014-01-01T00:00:06'): self.assertIsNone(CacheService.fetch_value_for_key('fake_key'), )
def test_ttl(self): """Test that a key can expire.""" with freeze_time('2014-01-01T00:00:00'): CacheService.set_value_for_key('fake_key', 'fake_value', ttl=5) self.assertEquals( CacheService.fetch_value_for_key('fake_key'), 'fake_value', ) with freeze_time('2014-01-01T00:00:06'): self.assertIsNone( CacheService.fetch_value_for_key('fake_key'), )