Spaces:
Sleeping
Sleeping
Download services/cache_service.py from Qurrah/replyflow-rag: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/services/cache_service.py
- Command line
-
hf download hf://spaces/Qurrah/replyflow-rag/services/cache_service.py
-
curl -L -o cache_service.py https://huggingface.co/spaces/Qurrah/replyflow-rag/resolve/main/services/cache_service.py
1.17 kB
| 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) | |
| ) | |