Calmcode - diskcache: features

Extra Features

1 2 3 4 5

The benefit of interacting with the cache directly is that we can also add extra information into our cache and query it. For example, when we set a key/value pair we can add a tag as well as an expire param.

# Setting extra information, add metadata and an expiry moment
cache.set('a', 1, expire=10, tag='demo tag')

# Getting the extra info back with retry and default
value, expire_ts, tag = cache.get('a', default=0, expire_time=True, tag=True, retry=5, )
value, expire_ts, tag

When you run that final cache.get a few times you'll also see when the database is empty.