A simple Python dict with TTL support for auto-expiring caches with support for case-insensitive keys.
Project description
expiring-cache
A simple Python dict with TTL support for auto-expiring caches with support for case-insensitive keys.
Installation
pip install expiring-cache
Features
- TTL support for auto-caching
- Case-insensitive keys support
Usage
Example 1:
import time
from cache import ExpiringCache
cache = ExpiringCache(2) # Keys will exist for 2 seconds.
cache['ABC'] = 'Example value'
print(cache['ABC']) # Prints the 'Example Value'
time.sleep(2)
print(cache['ABC']) # Raises KeyError
Example 2: (shows case-insensitive feature)
import time
from cache import ExpiringCache
cache = ExpiringCache(2, case_insensitive=True)
cache['ABC'] = 'Example value'
print(cache['ABC'])
print(cache['abc'])
# Both print statements above print the exact same 'Example Value'
time.sleep(2)
print(cache['ABC'])
print(cache['abc'])
# Both the print statements above raise KeyError
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
expiring-cache-1.0.0.tar.gz
(3.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file expiring-cache-1.0.0.tar.gz.
File metadata
- Download URL: expiring-cache-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335636f2669659988563ff9a92beb3d6e0a639146e4c2d8f944c358cbbd7b8f5
|
|
| MD5 |
7e2669f3a3d1268f978d18830b4860d3
|
|
| BLAKE2b-256 |
2115dcd7e376f2b4d7f57711e53263219ea0ae11bbe348b8ef26b09a072472de
|
File details
Details for the file expiring_cache-1.0.0-py3-none-any.whl.
File metadata
- Download URL: expiring_cache-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b527f067e693c7739a9c8d5b7c219f7d24b50e659725de9edf0d546b24cb46
|
|
| MD5 |
b31ba12a2220d1097d6d748799a1daea
|
|
| BLAKE2b-256 |
bae4295baf025695a71b0527f9e6bb235e4e1190e3e9e9b1545e01134d8119fe
|