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 hashes)
Built Distribution
Close
Hashes for expiring_cache-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0b527f067e693c7739a9c8d5b7c219f7d24b50e659725de9edf0d546b24cb46 |
|
MD5 | b31ba12a2220d1097d6d748799a1daea |
|
BLAKE2b-256 | bae4295baf025695a71b0527f9e6bb235e4e1190e3e9e9b1545e01134d8119fe |