Проблема:
Вы хотите использовать SafeCache из cache3, как показано в Quickstart
safecache_example.py
from cache3 import SafeCache
cache = SafeCache()но вместо этого видите следующее сообщение об ошибке:
error.txt
ImportError: cannot import name 'SafeCache' from 'cache3' (/usr/local/lib/python3.10/dist-packages/cache3/__init__.py)Решение
cache3 был обновлён, но документация до сих пор не исправлена. Это известный баг.
Ближайший эквивалент — Cache() с thread_safe=True, кэш в памяти, который поддерживает тегирование:
cache_replacement_example.py
from cache3 import Cache
cache = Cache(name="mycache", thread_safe=True)Если вам не нужно тегирование, рассмотрите MiniCache:
minicache_example.py
from cache3 import MiniCache
cache = MiniCache(name="mycache", thread_safe=True)
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow