def purge_from_autocomplete_caches(key, cachekey_base, prefixes): for cache in [SetQueryCache.fetch(cachekey_base % prefix) for prefix in prefixes]: try: cache.remove(key) cache.save() except KeyError: pass
def add_to_autocomplete_caches(key, cachekey_base, prefixes): for cache in [SetQueryCache.fetch(cachekey_base % prefix) for prefix in prefixes]: cache.add(key) cache.save()