CachemonCache: A Python Package for Caching
CachemonCache is a package that provides efficient and fast caching in Python, including
- Caching with different eviction algorithms, e.g., FIFO, LRU, S3FIFO, Sieve
- Tiered caching using your flash
- Thread-safe caches for multi-threaded applications
It uses a similar interface as dict so it can be used as a drop-in replacement for Python dict to save space.
News
- 2023-08-01: CachemonCache is under development!
Installation
pip install CachemonCache
Usage
# you can import FIFO, LRU, S3FIFO, Sieve
from cachemonCache import LRU
from cachemonCache import S3FIFO
# create a cache backed by DRAM, use S3FIFO eviction if you care about hit ratio
cache = LRU(size=10) # or cache = S3FIFO(size=10)
# create a cache backed by your local flash, size is the number of objects in DRAM cache
cache = S3FIFO(size=1000, flash_size_mb=1000, path="/disk/cachmon.data")
# put an item into the cache
cache.put("key", "value") # or cache["key"] = "value"
# you can specify a TTL using cache.put("key", "value", ttl=10)
# get an item from the cache
cache.get("key")
# delete an item from the cache
cache.delete("key") # or del cache["key"]
# check if an item is in the cache
"key" in cache # or cache.has("key")
# get the size of the cache
len(cache)
# add a callback for eviction
def callback(key, value, *args, **kwargs):
print("key: {}, value: {}".format(key, value))
cache.add_callback(callback)
# list all items in the cache
print(cache.items()) # or print(cache.keys())
# get some stat
print(cache.stats()) # or cache.miss_ratio()
Cachemon can also be used as a decorator to cache the return value of a function similar to the functools in standard library.
from cachemonCache import S3FIFO
@S3FIFO(size=1000, flash_size_mb=1000, path="/disk/cachmon.data")
def foo(x):
return x + 1
Benchmark
Python RocksDB
Road map
- support multi-threading
- support flash
Contributing
We welcome contributions to Cachemon! Please check out our contributing guide for more details.
Metadata
Release files for cachemonCache 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cachemoncache-0.0.2.tar.gz | 10.2 kB | Without provenance | Details for cachemoncache-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cachemoncache-0.0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for cachemoncache-0.0.2-py2.py3-none-any.whl |
Total release size: 27.1 kB
Release files / cachemoncache-0.0.2.tar.gz
| Download URL | cachemoncache-0.0.2.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4471a4d42453a093a799724457f754e8e63503ff28236d678e53c8b20b38dfca
|
|
BLAKE2b-256 checksum How to use checksums |
20e4a7073a8c0631205e56f5b66cf12d7e32138ed8af51d18d262653bcb3af6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Release files / cachemoncache-0.0.2-py2.py3-none-any.whl
| Download URL | cachemoncache-0.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4a7a6adf1b9aa1611b8b0861c8d7c44b07bef4b7fcd8ee2238fa7e1558079de5
|
|
BLAKE2b-256 checksum How to use checksums |
7215aa921aa9af285a29fb213dc0ba3fffe66bb57838ff048bbbce6e2c915939
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.12
|
Security for cachemonCache 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.