def test_delete(self, mock_cache_delete): TieredCache.set_all_tiers(TEST_KEY, EXPECTED_VALUE) TieredCache.set_all_tiers(TEST_KEY_2, EXPECTED_VALUE) TieredCache.delete_all_tiers(TEST_KEY) self.assertFalse( self.request_cache.get_cached_response(TEST_KEY).is_found) self.assertEqual( self.request_cache.get_cached_response(TEST_KEY_2).value, EXPECTED_VALUE) mock_cache_delete.assert_called_with(TEST_KEY)
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): """ Clear the cached value when saving a new configuration entry """ # Always create a new entry, instead of updating an existing model self.pk = None # pylint: disable=invalid-name super(ConfigurationModel, self).save(force_insert, force_update, using, update_fields) TieredCache.delete_all_tiers( self.cache_key_name( *[getattr(self, key) for key in self.KEY_FIELDS])) if self.KEY_FIELDS: TieredCache.delete_all_tiers(self.key_values_cache_key_name())