Spaces:
Sleeping
Sleeping
File size: 1,169 Bytes
efd039f 8ec9671 efd039f 1c0a11d efd039f 1c0a11d efd039f 1c0a11d efd039f 1c0a11d efd039f 1c0a11d efd039f 1c0a11d efd039f 1c0a11d efd039f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from repositories.social_account import list_channel_identifiers_for_workspace
from repositories.workspace import get_workspace_id_by_slug
from core.cache import credentials_cache, instant_reply_cache, product_result_cache
def clear_all_caches() -> None:
instant_reply_cache.clear()
credentials_cache.clear()
product_result_cache.clear()
def clear_product_result_cache_for_slug(brand_slug: str) -> int:
workspace_id = get_workspace_id_by_slug(brand_slug)
channel_identifiers = list_channel_identifiers_for_workspace(workspace_id)
def matches(key: str) -> bool:
return any(
key.startswith(f"query:{identifier}:")
for identifier in channel_identifiers
)
return instant_reply_cache.delete_matching(matches) + product_result_cache.delete_matching(matches)
def clear_instant_reply_cache() -> None:
instant_reply_cache.clear()
def clear_instant_reply_cache_for_identifier(channel_identifier: str) -> int:
return (
instant_reply_cache.delete_matching(lambda key: channel_identifier in key)
+ product_result_cache.delete_matching(lambda key: channel_identifier in key)
)
|