AutoCache
A lightweight and easy-to-use caching library for Python with support for automatic cache expiration.
Features
- Simple
@cache()decorator - Optional cache expiration (TTL)
- Cache hit/miss statistics
- Clear the cache at any time
- Lightweight with no external dependencies
Installation
pip install autocache
Quick Start
from autocache import cache
@cache()
def slow_function(x):
print("Running...")
return x * 2
print(slow_function(5))
print(slow_function(5))
Output:
Running...
10
10
Notice that "Running..." is only printed once because the second call is returned from the cache.
Cache Expiration
from autocache import cache
@cache(expire=5)
def get_data():
print("Fetching data...")
return "Hello"
get_data()
After 5 seconds, the cached value expires and the function will run again.
Cache Statistics
from autocache import cache_info
cache_info()
Example output:
Autocache
----------------
Entries: 2
Hits: 5
Misses: 3
Clearing the Cache
from autocache import clear_cache
clear_cache()
Roadmap
- In-memory caching
- Cache expiration
- Cache statistics
- Clear cache
- Support both
@cacheand@cache(...) - Maximum cache size
- Disk caching
- Async support
License
MIT License
Metadata
Release files for autocache-python 0.2.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 | |
|---|---|---|---|
| autocache_python-0.2.0.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autocache_python-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / autocache_python-0.2.0.tar.gz
| Download URL | autocache_python-0.2.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02bfca818d12f0894614de530a8d0b0495fce855ebdc3d401cbfb6abaa63a4af
|
|
BLAKE2b-256 checksum How to use checksums |
7f3d2420595e256c7e43cac572d3bb7527728ec7a15ab8e8b861c8cca8cec144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / autocache_python-0.2.0-py3-none-any.whl
| Download URL | autocache_python-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dffd1cbb70c9fa7fb007122518743c1d81ae528db095786c40d6bf4147c1cd35
|
|
BLAKE2b-256 checksum How to use checksums |
eedaa13b7a2ccc4243bfc9a2084c4a02975df7114f720ca0e32cab296a693cd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|