Skip to main content

Another dictionary with expiring keys.

Project description

ttldict2

Another dictionary with expiring keys.

Details

There are quire a few expiring/ttl dictionary libraries available. This one might be a better choice for you if:

  • Only need support for Python 3.7+ or PyPy3
  • Use it in a single/asyncio thread
  • Work correctly regardless of system-clock adjustments

The implementation is a wrapper around the builtin dict. As a design choice the methods that are not wrapped with TTL logic are accessible and can be used with caution.

Install & usage

A source distribution is available on PyPI:

$ python -m pip install ttldict2
>>> import time
>>> import ttldict2
>>> d = ttldict2.TTLDict(ttl_seconds=1.0)
>>> d["a"] = 5
>>> d.get("a")
5
>>> time.sleep(1.1)
>>> d.get("a")
None

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ttldict2, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size ttldict2-0.1.0-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ttldict2-0.1.0.tar.gz (7.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page