Cache¶
FileCache¶
ocx_mirror_sdk.cache.FileCache
¶
TTL-based blob cache with domain separation.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Namespace subdirectory (e.g.
TYPE:
|
max_age
|
Maximum age of cache entries in seconds.
TYPE:
|
root
|
Root cache directory. Defaults to the value set by
:func:
TYPE:
|
Source code in src/ocx_mirror_sdk/cache.py
get
¶
Return cached bytes for key, or None on miss / expiry.
| RAISES | DESCRIPTION |
|---|---|
CacheError
|
The on-disk entry exists but cannot be read. |
Source code in src/ocx_mirror_sdk/cache.py
put
¶
Store data under key. No-op when caching is disabled.
| RAISES | DESCRIPTION |
|---|---|
CacheError
|
Writing the entry failed (disk full, permission). |
Source code in src/ocx_mirror_sdk/cache.py
fetch
¶
Return cached bytes or call loader, cache the result, and return it.
Source code in src/ocx_mirror_sdk/cache.py
get_json
¶
Return the deserialized JSON object for key, or None on miss.
| RAISES | DESCRIPTION |
|---|---|
CacheError
|
The on-disk entry exists but is not valid JSON. |
Source code in src/ocx_mirror_sdk/cache.py
put_json
¶
fetch_json
¶
Return cached JSON or call loader, cache the result, and return it.
Unlike :meth:fetch, the loader returns a JSON-serializable object
(not raw bytes) and the return value is the deserialized object.
Source code in src/ocx_mirror_sdk/cache.py
configure¶
ocx_mirror_sdk.cache.configure
¶
Override SDK-wide cache settings.
| PARAMETER | DESCRIPTION |
|---|---|
cache_root
|
New default cache root directory. Use
TYPE:
|
Example
from pathlib import Path from ocx_mirror_sdk import configure configure(cache_root=Path("/tmp/my-cache"))