CacheCraft
CacheCraft is a custom in-memory caching system designed to improve application performance by storing and retrieving data with low-latency access.
This Project is fully inspired by Memcached
How to Use?
pip install CacheCraft
Example 1 (General Set & Get)
>>> from cachecraft.cache import CacheCraft
>>> cache = CacheCraft()
>>> cache.set('key', 'value')
>>> cache.get('key')
'value'
Example 2 (With Size and Default Time to live logic)
>>> cache = CacheCraft(max_size =100, default_ttl =2)
>>> cache.set('key', 'value')
>>> cache.get('key')
'value'
>>> import time; time.sleep(2)
>>> cache.get('key')
>>>
Example 3 (Least Recently Used LRU)
# Size is 3 so, if 4rth key will be added then
# oldest used will be removed
>>> from cachecraft.cache import CacheCraft
>>> cache = CacheCraft(max_size=3, default_ttl=30)
>>> cache.set('a', 1)
>>> cache.set('b', 2)
>>> cache.set('c', 3)
>>> cache.get('a')
1
>>> cache.get('c')
3
>>> cache.set('d', 4) # Once 'd' will set 'b' will be removed
>>> cache.get('b') # due to LRU
>>>
Validating through Testcase
git clone git@github.com:Aditya-1998k/CacheCraft.git
pip install pytest
pytest tests/
Project Structure
CacheCraft/
├── cachecraft/
│ ├── __init__.py # Package init file
│ ├── cache.py # Core caching logic
├── tests/
│ ├── test_cache.py # pytest
├── setup.py # Setup configuration for PyPI
├── README.md # Project description
└── LICENSE # License file
Features
1. Key-value store
2. Expiration : Optionally set TTl (time to live)
3. LRU Eviction Policy : Automatically evicts the least recently used entries
6. Customizable: Modify cache size, eviction policy etc.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for CacheCraft 0.1.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 | |
|---|---|---|---|
| cachecraft-0.1.2.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| CacheCraft-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / cachecraft-0.1.2.tar.gz
| Download URL | cachecraft-0.1.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7607455c63aa9f2d3598b5cc222c28415c20030246d81de41529598ec16548e7
|
|
BLAKE2b-256 checksum How to use checksums |
1136326403ea35c86f7abe5dd2844bbde9be0b1af8d1c0709b179dc653459513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / CacheCraft-0.1.2-py3-none-any.whl
| Download URL | CacheCraft-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75c7031dddb80ae6fc026af348c3e8968ea24710f1f98ed95628987bd2e709ce
|
|
BLAKE2b-256 checksum How to use checksums |
8dcbc63a0e79a472967a94439cb0a88f01399a8716ba6b6f0d8808578f1ac696
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|