def test_invalidate_cache_user_profile_country_updated(self): country = 'us' self.profile.country = country self.profile.save() cache_key = UserProfile.country_cache_key_name(self.user.id) self.assertIsNone(cache.get(cache_key)) cache.set(cache_key, self.profile.country) self.assertEqual(cache.get(cache_key), country) country = 'bd' self.profile.country = country self.profile.save() self.assertNotEqual(cache.get(cache_key), country) self.assertIsNone(cache.get(cache_key))
def delete_users_country_cache(user): cache_key = UserProfile.country_cache_key_name(user.id) cache.delete(cache_key)