pcache is simple Python 3 implementation of persistent cache.
To install pcache
, simply run
pip install pcache
Adding a key
>>> from pcache import PersistentCache
>>> cache = PersistentCache(filename="cachefile")
>>> cache["objId"] = "7sdjhds8"
>>> cache["objId"]
'7sdjhds8'
Cache Expiry
>>> cache.expire("objId", ttl=30) # Expire key in 30 seconds
>>> import time
>>> time.sleep(35)
>>> print(cache["objId"])
None