Skip to main content

Python dict with TTL support for auto-expiring caches

Project description

py-expiring-dict

Python dict with TTL support for auto-expiring caches

Install

pip install expiring-dict

Usage

Class Level TTL

from time import sleep
from expiring_dict import ExpiringDict

cache = ExpiringDict(1)  # Keys will exist for 1 second

cache["abc123"] = "some value"
assert "abc123" in cache
sleep(1)
assert "abc123" not in cache

Key Level TTL

from time import sleep
from expiring_dict import ExpiringDict

cache = ExpiringDict()  # No TTL set, keys set via [] will not expire

cache["abc"] = "persistent"
cache.ttl("123", "expired", 1)  # This will expire after 1 second
assert "abc" in cache
assert "123" in cache
sleep(1)
assert "abc" in cache
assert "123" not in cache

Project details


Download files

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

Source Distribution

expiring-dict-1.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

expiring_dict-1.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file expiring-dict-1.1.1.tar.gz.

File metadata

  • Download URL: expiring-dict-1.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for expiring-dict-1.1.1.tar.gz
Algorithm Hash digest
SHA256 277942edc60d5b123457c1a468698c94923dbfac8d40b263b921c04e6940dc09
MD5 3c5fe36867986ecc01f6e6f3b02e176e
BLAKE2b-256 61f874423159ad15b2f48f0dde2aea000a6892aed8a33171ec424104e5ad4740

See more details on using hashes here.

File details

Details for the file expiring_dict-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for expiring_dict-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5387bfc1cac9b4e78d37ab787a438ca29e20c6d360a230ed3ce8cfca088d53f
MD5 822f81401e5d015a0587ff3b98f2a879
BLAKE2b-256 00bbeb786bb0cbc257d9cba8bb0737223ffce336fa9b3e9ab6ddc6b337b0d6ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page