A simple implementation of SIEVE caching algorithm
Project description
sieve.cache
sieve.cache is a lightweight Python cache utility that implements the
SIEVE eviction algorithm on top of dogpile.cache backends.
Project Summary
- Implements a
Sievecache with a decorator-based API. - Uses a doubly linked list (
head,tail,hand) to track entries. - Applies SIEVE eviction using a
visitedbit on each node. - Integrates with
dogpile.cacheregions and key generation. - Includes an in-memory backend adapter (
sieve_cache.memory).
How It Works
When a decorated function is called:
- A cache key is generated from function arguments.
- If the key exists, the node is marked as visited and returned.
- On a miss, the function is executed and result cached.
- If cache size reaches
max_size, an item is evicted by SIEVE.
The eviction pointer (hand) scans backward, clears visited=True nodes,
and removes the first unvisited candidate.
Installation
Install from source:
pip install sieve-cache
Quick Usage
import sieve_cache
cache = sieve_cache.create_sieve(backend="sieve_cache.memory")
@cache.cache(max_size=128)
def expensive_call(x: int) -> int:
return x * x
print(expensive_call(5))
print(expensive_call(5)) # cached
Project Layout
sieve_cache/sieve.py: Core SIEVE cache implementation and decorator.sieve_cache/node.py: Cache node model used by linked-list structure.sieve_cache/backends/memory.py: In-memorydogpile.cachebackend.sieve_cache/__init__.py: Region/backend configuration and factory helpers.
References
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
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 sieve_cache-0.0.1.tar.gz.
File metadata
- Download URL: sieve_cache-0.0.1.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5910bdf60b3dc579f477b3108312f96b3fa7d81a1bb87d7c8cffb3f6cb1720ac
|
|
| MD5 |
be81cd4d8422de35a01db0f2bc473a49
|
|
| BLAKE2b-256 |
9bb075002867173427f8211ad4ed9dbcce0d6c86f74f7643025bca3a0536b7d8
|
Provenance
The following attestation bundles were made for sieve_cache-0.0.1.tar.gz:
Publisher:
release-pypi.yml on daipham3213/sieve.cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sieve_cache-0.0.1.tar.gz -
Subject digest:
5910bdf60b3dc579f477b3108312f96b3fa7d81a1bb87d7c8cffb3f6cb1720ac - Sigstore transparency entry: 1113909996
- Sigstore integration time:
-
Permalink:
daipham3213/sieve.cache@5f31b06cc703b6918b000f87a9e11719d80c8d3e -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/daipham3213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@5f31b06cc703b6918b000f87a9e11719d80c8d3e -
Trigger Event:
release
-
Statement type:
File details
Details for the file sieve_cache-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sieve_cache-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ae62213e713b9b8ae0822e572d64ba78e09fbc0b5e932caa33f87111fc8b20
|
|
| MD5 |
15ebf169656a6c858628d6a79dfde8aa
|
|
| BLAKE2b-256 |
00f170757a645d27d45541c4170c09e44d354d94379cdc0ffcdd0f7722257fff
|
Provenance
The following attestation bundles were made for sieve_cache-0.0.1-py3-none-any.whl:
Publisher:
release-pypi.yml on daipham3213/sieve.cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sieve_cache-0.0.1-py3-none-any.whl -
Subject digest:
e0ae62213e713b9b8ae0822e572d64ba78e09fbc0b5e932caa33f87111fc8b20 - Sigstore transparency entry: 1113910047
- Sigstore integration time:
-
Permalink:
daipham3213/sieve.cache@5f31b06cc703b6918b000f87a9e11719d80c8d3e -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/daipham3213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@5f31b06cc703b6918b000f87a9e11719d80c8d3e -
Trigger Event:
release
-
Statement type: