longcache 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- longcache-0.1.0/.gitignore +78 -0
- longcache-0.1.0/CHANGELOG.md +38 -0
- longcache-0.1.0/LICENSE +21 -0
- longcache-0.1.0/PKG-INFO +942 -0
- longcache-0.1.0/README.md +878 -0
- longcache-0.1.0/pyproject.toml +141 -0
- longcache-0.1.0/src/longcache/__init__.py +11 -0
- longcache-0.1.0/src/longcache/backends/__init__.py +21 -0
- longcache-0.1.0/src/longcache/backends/async_redis.py +274 -0
- longcache-0.1.0/src/longcache/backends/base.py +167 -0
- longcache-0.1.0/src/longcache/backends/memory.py +243 -0
- longcache-0.1.0/src/longcache/backends/redis.py +374 -0
- longcache-0.1.0/src/longcache/backends/sqlite.py +521 -0
- longcache-0.1.0/src/longcache/cli.py +216 -0
- longcache-0.1.0/src/longcache/config.py +127 -0
- longcache-0.1.0/src/longcache/core/__init__.py +8 -0
- longcache-0.1.0/src/longcache/core/base_embedder.py +43 -0
- longcache-0.1.0/src/longcache/core/cache.py +872 -0
- longcache-0.1.0/src/longcache/core/embedder.py +155 -0
- longcache-0.1.0/src/longcache/core/entry.py +122 -0
- longcache-0.1.0/src/longcache/core/index.py +272 -0
- longcache-0.1.0/src/longcache/integrations/__init__.py +32 -0
- longcache-0.1.0/src/longcache/integrations/langchain.py +316 -0
- longcache-0.1.0/src/longcache/integrations/langgraph.py +150 -0
- longcache-0.1.0/src/longcache/integrations/llamaindex.py +103 -0
- longcache-0.1.0/src/longcache/integrations/openai.py +146 -0
- longcache-0.1.0/src/longcache/middleware.py +366 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.egg
|
|
9
|
+
*.egg-info/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
eggs/
|
|
13
|
+
parts/
|
|
14
|
+
var/
|
|
15
|
+
sdist/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
.installed.cfg
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
*.manifest
|
|
21
|
+
*.spec
|
|
22
|
+
*.whl
|
|
23
|
+
*.tar.gz
|
|
24
|
+
*.zip
|
|
25
|
+
|
|
26
|
+
# Installer logs
|
|
27
|
+
pip-log.txt
|
|
28
|
+
pip-delete-this-directory.txt
|
|
29
|
+
|
|
30
|
+
# Unit test / coverage reports
|
|
31
|
+
htmlcov/
|
|
32
|
+
.tox/
|
|
33
|
+
.nox/
|
|
34
|
+
.coverage
|
|
35
|
+
.coverage.*
|
|
36
|
+
.cache
|
|
37
|
+
nosetests.xml
|
|
38
|
+
coverage.xml
|
|
39
|
+
*.cover
|
|
40
|
+
*.py,cover
|
|
41
|
+
.hypothesis/
|
|
42
|
+
.pytest_cache/
|
|
43
|
+
.mypy_cache/
|
|
44
|
+
.ruff_cache/
|
|
45
|
+
|
|
46
|
+
# Environments
|
|
47
|
+
.env
|
|
48
|
+
.venv
|
|
49
|
+
env/
|
|
50
|
+
venv/
|
|
51
|
+
ENV/
|
|
52
|
+
env.bak/
|
|
53
|
+
venv.bak/
|
|
54
|
+
.uv/
|
|
55
|
+
|
|
56
|
+
# mkdocs
|
|
57
|
+
site/
|
|
58
|
+
|
|
59
|
+
# IDE and editors
|
|
60
|
+
.idea/
|
|
61
|
+
.vscode/
|
|
62
|
+
*.swp
|
|
63
|
+
*.swo
|
|
64
|
+
*~
|
|
65
|
+
.DS_Store
|
|
66
|
+
Thumbs.db
|
|
67
|
+
|
|
68
|
+
# LongCache local cache artifacts
|
|
69
|
+
.longcache/
|
|
70
|
+
*.db
|
|
71
|
+
*.sqlite
|
|
72
|
+
*.sqlite3
|
|
73
|
+
cache.db
|
|
74
|
+
test_cache.db
|
|
75
|
+
|
|
76
|
+
# HuggingFace model cache (local downloads)
|
|
77
|
+
.cache/
|
|
78
|
+
models/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-10-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Core Semantic Cache Engine:**
|
|
15
|
+
- Fast local embeddings using `BAAI/bge-small-en-v1.5` (384-dimensional dense vectors) running fully offline.
|
|
16
|
+
- FAISS index integration with support for exact flat cosine similarity and scalable HNSW indexing.
|
|
17
|
+
- Transparent sync and async decorator `@cache.cached` with parameter hashing, TTL expiry, and namespace scoping.
|
|
18
|
+
- Composite cache keys to prevent cross-model poisoning (scoped by model, system prompt, temperature, and query).
|
|
19
|
+
- **Pluggable Storage Backends:**
|
|
20
|
+
- `SQLiteBackend`: Zero-configuration local disk persistence with transactional safety and WAL mode.
|
|
21
|
+
- `RedisBackend` & `AsyncRedisBackend`: High-throughput distributed caching for multi-container and cluster deployments.
|
|
22
|
+
- `MemoryBackend`: High-speed in-memory storage for unit tests, ephemeral workers, and local experiments.
|
|
23
|
+
- **Framework Integrations:**
|
|
24
|
+
- `langchain`: Semantic caching adapter for LangChain LLMs and runnables.
|
|
25
|
+
- `langgraph`: Contextual state cache node for multi-agent workflows.
|
|
26
|
+
- `llamaindex`: Semantic cache wrapper for LlamaIndex query engines.
|
|
27
|
+
- `openai`: Drop-in wrapper for `openai.OpenAI` and `openai.AsyncOpenAI` chat completions.
|
|
28
|
+
- `fastapi`: ASGI HTTP middleware for automatic semantic caching of REST / SSE endpoints.
|
|
29
|
+
- **CLI & Diagnostics:**
|
|
30
|
+
- `longcache stats`: Real-time cache hit rate, token savings, and cost metrics.
|
|
31
|
+
- `longcache clear`: Scoped namespace and total cache eviction.
|
|
32
|
+
- `longcache inspect`: Query lookup, similarity breakdown, and payload inspection.
|
|
33
|
+
- `longcache export`: JSON and CSV dataset exporting for cache analytics.
|
|
34
|
+
- **Developer Tools & CI/CD:**
|
|
35
|
+
- CI workflow with Python 3.10, 3.11, and 3.12 test matrix.
|
|
36
|
+
- Automated GitHub Pages documentation deployment with Material for MkDocs.
|
|
37
|
+
- Auto-tagging and GitHub release generation on main branch merge.
|
|
38
|
+
- Automated PyPI publishing pipeline with Trusted Publisher authentication.
|
longcache-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ENDEVSOLS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|