cloud-dog-cache 0.2.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.
Files changed (38) hide show
  1. cloud_dog_cache-0.2.0/.docs-manifest.yml +6 -0
  2. cloud_dog_cache-0.2.0/.gitignore +1 -0
  3. cloud_dog_cache-0.2.0/ARCHITECTURE.md +40 -0
  4. cloud_dog_cache-0.2.0/BUILD.md +64 -0
  5. cloud_dog_cache-0.2.0/CHANGELOG.md +37 -0
  6. cloud_dog_cache-0.2.0/DATA-MODEL.md +33 -0
  7. cloud_dog_cache-0.2.0/LICENCE +13 -0
  8. cloud_dog_cache-0.2.0/NOTICE +24 -0
  9. cloud_dog_cache-0.2.0/PKG-INFO +16 -0
  10. cloud_dog_cache-0.2.0/README.md +28 -0
  11. cloud_dog_cache-0.2.0/REQUIREMENTS.md +37 -0
  12. cloud_dog_cache-0.2.0/TESTS.md +37 -0
  13. cloud_dog_cache-0.2.0/cloud_dog_cache/__init__.py +84 -0
  14. cloud_dog_cache-0.2.0/cloud_dog_cache/access.py +386 -0
  15. cloud_dog_cache-0.2.0/cloud_dog_cache/api.py +37 -0
  16. cloud_dog_cache-0.2.0/cloud_dog_cache/backends/__init__.py +9 -0
  17. cloud_dog_cache-0.2.0/cloud_dog_cache/backends/base.py +39 -0
  18. cloud_dog_cache-0.2.0/cloud_dog_cache/backends/memory.py +91 -0
  19. cloud_dog_cache-0.2.0/cloud_dog_cache/backends/redis.py +102 -0
  20. cloud_dog_cache-0.2.0/cloud_dog_cache/decorator.py +94 -0
  21. cloud_dog_cache-0.2.0/cloud_dog_cache/invalidation.py +31 -0
  22. cloud_dog_cache-0.2.0/cloud_dog_cache/keys.py +59 -0
  23. cloud_dog_cache-0.2.0/cloud_dog_cache/manager.py +95 -0
  24. cloud_dog_cache-0.2.0/cloud_dog_cache/memory.py +206 -0
  25. cloud_dog_cache-0.2.0/cloud_dog_cache/models.py +41 -0
  26. cloud_dog_cache-0.2.0/cloud_dog_cache/runtime.py +57 -0
  27. cloud_dog_cache-0.2.0/cloud_dog_cache/stats.py +36 -0
  28. cloud_dog_cache-0.2.0/pyproject.toml +24 -0
  29. cloud_dog_cache-0.2.0/tests/__init__.py +2 -0
  30. cloud_dog_cache-0.2.0/tests/env-UT +2 -0
  31. cloud_dog_cache-0.2.0/tests/quality/QT_PUBLISH_COMPLIANCE/__init__.py +2 -0
  32. cloud_dog_cache-0.2.0/tests/quality/__init__.py +2 -0
  33. cloud_dog_cache-0.2.0/tests/test_memory.py +181 -0
  34. cloud_dog_cache-0.2.0/tests/unit/__init__.py +2 -0
  35. cloud_dog_cache-0.2.0/tests/unit/test_access_url.py +314 -0
  36. cloud_dog_cache-0.2.0/tests/unit/test_decorator.py +85 -0
  37. cloud_dog_cache-0.2.0/tests/unit/test_keys.py +49 -0
  38. cloud_dog_cache-0.2.0/tests/unit/test_memory_backend.py +86 -0
@@ -0,0 +1,6 @@
1
+ schema-version: 1.0
2
+ project: platform-cache
3
+ canon-set: PACKAGE
4
+ canon-template-baseline: 1.0
5
+ conditional-docs: []
6
+ additional-docs: []
@@ -0,0 +1 @@
1
+ tmp/
@@ -0,0 +1,40 @@
1
+ ---
2
+ template-id: T-PKG-ARC
3
+ template-version: 1.0
4
+ applies-to: ARCHITECTURE.md
5
+ registry: package
6
+ required: must-have
7
+ when-applicable: ""
8
+ template-last-updated: 2026-06-12
9
+ template-owner: platform-standards
10
+
11
+ project: platform-cache
12
+ public: true
13
+ doc-last-updated: 2026-06-12
14
+ doc-git-commit: no-git
15
+ doc-git-branch: main
16
+ doc-source-shas: []
17
+ doc-age-policy: indefinite
18
+ doc-conformance-stamp: 2026-06-12T12:00:00Z
19
+ ---
20
+
21
+ # platform-cache — ARCHITECTURE
22
+
23
+ > **Template version:** T-PKG-ARC v1.0
24
+
25
+ ## 1. Purpose
26
+ What problem the package solves.
27
+
28
+ ## 2. Modules
29
+ | Module | Responsibility |
30
+ |---|---|
31
+
32
+ ## 3. Relationships
33
+ Dependencies on other Cloud-Dog packages, external libs.
34
+
35
+ ## 4. Extension points
36
+ How consumers plug in.
37
+
38
+ ## 5. Cross-references
39
+ - [REQUIREMENTS.md](REQUIREMENTS.md), [DATA-MODEL.md](DATA-MODEL.md)
40
+ - Consumer services
@@ -0,0 +1,64 @@
1
+ # Build Instructions
2
+
3
+ ## Package
4
+ `cloud_dog_cache` - caching helpers for platform services.
5
+
6
+ ## Prerequisites
7
+ - Python 3.11+
8
+ - pip
9
+
10
+ ## Development Setup
11
+ ```bash
12
+ python3 -m venv .venv
13
+ source .venv/bin/activate
14
+ pip install --upgrade pip build twine pytest
15
+ pip install -e .
16
+ ```
17
+
18
+ To include the optional Redis extra:
19
+ ```bash
20
+ pip install -e .[redis]
21
+ ```
22
+
23
+ ## Local Use
24
+ ```bash
25
+ python -c "import cloud_dog_cache; print('package import ok')"
26
+ ```
27
+
28
+ ## Run Tests
29
+ ```bash
30
+ python -m pytest tests/unit -v
31
+ ```
32
+
33
+ ## Build Distribution
34
+ ```bash
35
+ python -m build
36
+ ```
37
+
38
+ ## Publish
39
+ ```bash
40
+ twine upload --repository-url $PYPI_URL dist/*
41
+ ```
42
+
43
+ ## Docker Packaging
44
+ ```bash
45
+ PYPI_URL=https://packages.example.com/simple/ \
46
+ PYPI_USERNAME=build-user \
47
+ PYPI_PASSWORD=build-password \
48
+ docker build -t cloud_dog_cache:latest .
49
+ ```
50
+
51
+ ## Dependencies
52
+ - optional Redis support is available through the `redis` extra
53
+ - see `pyproject.toml` for the exact dependency set
54
+
55
+ ## Configuration
56
+ This package does not require a dedicated env overlay for unit testing; configure cache backends with standard shell environment variables when embedding it in an application.
57
+
58
+ ## Vault Integration
59
+ ```bash
60
+ export VAULT_ADDR=https://vault.example.com
61
+ export VAULT_TOKEN=your-token
62
+ export VAULT_MOUNT_POINT=your-mount
63
+ export VAULT_CONFIG_PATH=your-path
64
+ ```
@@ -0,0 +1,37 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-05-04)
4
+
5
+ - **NEW: URL-addressable cache layer** (`cloud_dog_cache.access`)
6
+ - `URLAddressableCache` wraps a `CacheManager` to expose cache entries via
7
+ externally-fetchable URLs. Closes the architectural gap surfaced by W28A
8
+ #A16 (notification-agent's `ImageCacheManager` had no platform replacement
9
+ for its `access_url` semantic).
10
+ - `AccessUrlConfig` — `base_url`, `signing_secret`, `default_url_ttl_seconds`,
11
+ `access_path_prefix`.
12
+ - `AccessUrlEntry` — return shape for `set_with_url`, mirrors the historical
13
+ `ImageCacheManager.cache_image` response keys (cache_key, access_url, etc.).
14
+ - Two URL modes: **unsigned** (`{base}/cache/access/{key}` — assumes upstream
15
+ auth) and **signed** (HMAC-SHA256 over `key|expires_ts`, expiry verified
16
+ server-side at fetch time).
17
+ - URL TTL is independent of cache content TTL — long-lived cache entries can
18
+ mint short-lived signed URLs.
19
+ - `create_access_url_router(cache, *, media_type_resolver=None)` —
20
+ drop-in FastAPI router serving `GET {prefix}/{key}` with signature +
21
+ expiry validation.
22
+ - Pure additive change. No existing API surface modified. Backward compatible
23
+ with all 0.1.x consumers.
24
+
25
+ ## 0.1.1
26
+
27
+ - Patch release.
28
+
29
+ ## 0.1.0 (2026-03-27)
30
+
31
+ - Initial release
32
+ - In-memory LRU backend with TTL
33
+ - Redis backend (optional)
34
+ - @cached decorator for async functions
35
+ - Event-based invalidation (context_rebuild, config_change, prompt_change)
36
+ - Tag-based flush
37
+ - CacheStats model
@@ -0,0 +1,33 @@
1
+ ---
2
+ template-id: T-PKG-DMT
3
+ template-version: 1.0
4
+ applies-to: DATA-MODEL.md
5
+ registry: package
6
+ required: must-have
7
+ when-applicable: ""
8
+ template-last-updated: 2026-06-12
9
+ template-owner: platform-standards
10
+
11
+ project: platform-cache
12
+ public: true
13
+ doc-last-updated: 2026-06-12
14
+ doc-git-commit: no-git
15
+ doc-git-branch: main
16
+ doc-source-shas: []
17
+ doc-age-policy: indefinite
18
+ doc-conformance-stamp: 2026-06-12T12:00:00Z
19
+ ---
20
+
21
+ # platform-cache — DATA-MODEL
22
+
23
+ > **Template version:** T-PKG-DMT v1.0
24
+
25
+ ## 1. Exported types
26
+ | Type | Shape | Purpose |
27
+ |---|---|---|
28
+
29
+ ## 2. Persisted state
30
+ If the package owns persisted state, describe schema.
31
+
32
+ ## 3. Cross-references
33
+ - [ARCHITECTURE.md](ARCHITECTURE.md)
@@ -0,0 +1,13 @@
1
+ Copyright 2026 Cloud-Dog, Viewdeck Engineering Limited
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,24 @@
1
+ ---
2
+ template-id: T-PKG-NOT
3
+ template-version: 1.0
4
+ applies-to: NOTICE
5
+ registry: package
6
+ required: must-have
7
+ when-applicable: ""
8
+ template-last-updated: 2026-06-12
9
+ template-owner: platform-standards
10
+
11
+ project: platform-cache
12
+ public: true
13
+ doc-last-updated: 2026-06-12
14
+ doc-git-commit: no-git
15
+ doc-git-branch: main
16
+ doc-source-shas: []
17
+ doc-age-policy: indefinite
18
+ doc-conformance-stamp: 2026-06-12T12:00:00Z
19
+ ---
20
+
21
+ platform-cache
22
+ Copyright 2026 Cloud-Dog, Viewdeck Engineering Limited
23
+
24
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloud_dog_cache
3
+ Version: 0.2.0
4
+ Summary: Platform caching package for LLM and tool call results
5
+ Author: Cloud-Dog, Viewdeck Engineering Limited
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENCE
8
+ License-File: NOTICE
9
+ Requires-Python: >=3.10
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
12
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
13
+ Requires-Dist: pytest>=8.0; extra == 'dev'
14
+ Requires-Dist: ruff>=0.4; extra == 'dev'
15
+ Provides-Extra: redis
16
+ Requires-Dist: redis>=5.0; extra == 'redis'
@@ -0,0 +1,28 @@
1
+ # cloud_dog_cache
2
+
3
+ Platform caching package for LLM and tool call results.
4
+
5
+ ## Quick Start
6
+
7
+ ```python
8
+ from cloud_dog_cache import cached, init_cache, CacheConfig
9
+
10
+ # Initialise
11
+ init_cache(CacheConfig(enabled=True, backend="memory", ttl_seconds=3600))
12
+
13
+ # Decorate async functions
14
+ @cached(ttl=3600, invalidate_on=["context_rebuild"])
15
+ async def generate_sql(query: str, context_hash: str) -> str:
16
+ ...
17
+ ```
18
+
19
+ ## Backends
20
+
21
+ - `memory` (default) — In-memory LRU with configurable max entries
22
+ - `redis` — Redis-backed with tag-based invalidation
23
+
24
+ ## Invalidation
25
+
26
+ - TTL-based expiry
27
+ - Event-based: `invalidate_event("context_rebuild")`
28
+ - Manual: `await manager.flush()`
@@ -0,0 +1,37 @@
1
+ ---
2
+ template-id: T-PKG-REQ
3
+ template-version: 1.0
4
+ applies-to: REQUIREMENTS.md
5
+ registry: package
6
+ required: must-have
7
+ when-applicable: ""
8
+ template-last-updated: 2026-06-12
9
+ template-owner: platform-standards
10
+
11
+ project: platform-cache
12
+ public: true
13
+ doc-last-updated: 2026-06-12
14
+ doc-git-commit: no-git
15
+ doc-git-branch: main
16
+ doc-source-shas: []
17
+ doc-age-policy: indefinite
18
+ doc-conformance-stamp: 2026-06-12T12:00:00Z
19
+ ---
20
+
21
+ # platform-cache — REQUIREMENTS
22
+
23
+ > **Template version:** T-PKG-REQ v1.0
24
+
25
+ ## 1. Functional
26
+ | ID | Requirement | Consumer | Tests |
27
+ |---|---|---|---|
28
+
29
+ ## 2. Non-functional
30
+ | ID | Requirement | Measure |
31
+ |---|---|---|
32
+
33
+ ## 3. Compatibility
34
+ Python/Node versions, OS, peer-deps.
35
+
36
+ ## 4. Cross-references
37
+ - [ARCHITECTURE.md](ARCHITECTURE.md), [TESTS.md](TESTS.md)
@@ -0,0 +1,37 @@
1
+ ---
2
+ template-id: T-PKG-TST
3
+ template-version: 1.0
4
+ applies-to: TESTS.md
5
+ registry: package
6
+ required: must-have
7
+ when-applicable: ""
8
+ template-last-updated: 2026-06-12
9
+ template-owner: platform-standards
10
+
11
+ project: platform-cache
12
+ public: true
13
+ doc-last-updated: 2026-06-12
14
+ doc-git-commit: no-git
15
+ doc-git-branch: main
16
+ doc-source-shas: []
17
+ doc-age-policy: 90d
18
+ doc-conformance-stamp: 2026-06-12T12:00:00Z
19
+ ---
20
+
21
+ # platform-cache — TESTS
22
+
23
+ > **Template version:** T-PKG-TST v1.0
24
+
25
+ ## 1. Coverage
26
+ | Test ID | Module | Requirement | Tier |
27
+ |---|---|---|---|
28
+
29
+ ## 2. Running
30
+ ```bash
31
+ pytest # backend
32
+ npm test # frontend
33
+ ```
34
+
35
+ ## 3. Cross-references
36
+ - [REQUIREMENTS.md](REQUIREMENTS.md)
37
+ - PS-95-testing.md
@@ -0,0 +1,84 @@
1
+ # Copyright 2026 Cloud-Dog, Viewdeck Engineering Limited
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """cloud_dog_cache — Platform caching package for LLM and tool call results.
16
+
17
+ Provides a transparent caching layer with configurable TTL, pluggable backends
18
+ (in-memory LRU, Redis), and event-based invalidation for context rebuilds,
19
+ config changes, and prompt template changes.
20
+
21
+ Usage::
22
+
23
+ from cloud_dog_cache import cached, CacheManager, get_cache_manager
24
+
25
+ @cached(ttl=3600, invalidate_on=["context_rebuild"])
26
+ async def generate_sql(query: str, context_hash: str, model: str) -> str:
27
+ ...
28
+
29
+ # Manual access
30
+ manager = get_cache_manager()
31
+ await manager.flush()
32
+ stats = await manager.stats()
33
+ """
34
+
35
+ __version__ = "0.3.0"
36
+
37
+ from cloud_dog_cache.manager import CacheManager, get_cache_manager, init_cache
38
+ from cloud_dog_cache.decorator import cached
39
+ from cloud_dog_cache.keys import cache_key, hash_text, hash_config
40
+ from cloud_dog_cache.stats import CacheStats
41
+ from cloud_dog_cache.models import CacheConfig, CacheEntry
42
+ from cloud_dog_cache.invalidation import invalidate_event
43
+ from cloud_dog_cache.runtime import init_cache_from_config
44
+ from cloud_dog_cache.api import create_cache_router
45
+ from cloud_dog_cache.access import (
46
+ AccessUrlConfig,
47
+ AccessUrlEntry,
48
+ URLAddressableCache,
49
+ create_access_url_router,
50
+ )
51
+ from cloud_dog_cache.memory import (
52
+ MemoryScope,
53
+ MemoryNamespace,
54
+ MemoryEntry,
55
+ MemoryStore,
56
+ VectorSearchAdapter,
57
+ DEFAULT_SCOPE_TTL,
58
+ )
59
+
60
+ __all__ = [
61
+ "AccessUrlConfig",
62
+ "AccessUrlEntry",
63
+ "CacheConfig",
64
+ "CacheEntry",
65
+ "CacheManager",
66
+ "CacheStats",
67
+ "DEFAULT_SCOPE_TTL",
68
+ "MemoryEntry",
69
+ "MemoryNamespace",
70
+ "MemoryScope",
71
+ "MemoryStore",
72
+ "URLAddressableCache",
73
+ "VectorSearchAdapter",
74
+ "cached",
75
+ "cache_key",
76
+ "create_access_url_router",
77
+ "create_cache_router",
78
+ "get_cache_manager",
79
+ "hash_config",
80
+ "hash_text",
81
+ "init_cache",
82
+ "init_cache_from_config",
83
+ "invalidate_event",
84
+ ]