TimerDict
This package provides a simple dictionary-like class, which drops items after a set amount of time.
from datetime import timedelta
from typing import Union
# When creating a TimerDict specify for how long items should live for:
my_dict = TimerDict(default_duration=timedelta(minutes=5))
# Then add items like you would to any dictionary
my_dict["foo"] = "bar"
# Or use the `put` method if you want to explicitly set the duration for a key
my_dict.put('foo', 'bar', timedelta(seconds=10))
# Getting items also works just like you'd would expect
print(my_dict['foo'])
Implementation Details
Internally, the dict keeps a queue of all items and when they should be removed.
The items are then purged whenever control flow passes to the dictionary, such
as when adding or getting an item. There is no separate thread or async task
running in the background.
Metadata
Release files for timer-dict 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| timer_dict-1.0.0.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| timer_dict-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / timer_dict-1.0.0.tar.gz
| Download URL | timer_dict-1.0.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d53ae6d42bf722abdb9c061c6beb8a9d1ca9485e7c82c39decd43f64017e0215
|
|
BLAKE2b-256 checksum How to use checksums |
6d4b1d1a0720fc448f789d41297b6e063fc38e33f4df227f4a36436b6653c9e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.9 Linux/6.2.5-arch1-1
|
Release files / timer_dict-1.0.0-py3-none-any.whl
| Download URL | timer_dict-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90ba4f310c377a6813daecfa6fd3d7d4acdda45527d1b332a413a8bc0c0e04e6
|
|
BLAKE2b-256 checksum How to use checksums |
16bd8f6139e75a82f1de7e6e54f535f109c2b4e63a20cedbff15e816d7bee0dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.9 Linux/6.2.5-arch1-1
|