def clear_cache(key_prefix): keys = [ key for key in cache.cache._cache.keys() if key.startswith(key_prefix) ] cache.delete_many(*keys)
def clear_cache(key_prefix): """ This method uses iterates all the keys in the cache. If the key is prefixed with the passed in prefix, it will be places on the keys list. Lastly, the cache is cleared. :param key_prefix """ keys = [key for key in cache.cache._cache.keys() if key.startswith(key_prefix)] cache.delete_many(*keys)
def clear_cache(key_prefix): keys = [key for key in cache.cache._cache.keys() if key.startswith(key_prefix)] # The single star * unpacks the sequence/collection into positional arguments, so you can do this: cache.delete_many(*keys)
def clear_cache(key_prefix): """Function to clear the cache with a specific prefix""" keys = [ key for key in cache.cache._cache.keys() if key.startswith(key_prefix) ] cache.delete_many(*keys)