Problema:
Você quer usar cache3’s SafeCache como mostrado no Quickstart
safecache_example.py
from cache3 import SafeCache
cache = SafeCache()mas você em vez disso vê a seguinte mensagem de erro:
error.txt
ImportError: cannot import name 'SafeCache' from 'cache3' (/usr/local/lib/python3.10/dist-packages/cache3/__init__.py)Solução
cache3 foi atualizado, mas a documentação ainda não foi corrigida. Isso é um bug conhecido.
O equivalente mais próximo é Cache() com thread_safe=True, um cache em memória que suporta tagging:
cache_replacement_example.py
from cache3 import Cache
cache = Cache(name="mycache", thread_safe=True)Caso você não precise de tagging, considere 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