OpenKache Python client
OpenKache is a high-performance cache server designed from the ground up for modern SSDs. Use this Python client to store, read, and delete values in a few lines.
Install
Python 3.11 or newer is required.
# pip
python -m pip install openkache
# uv
uv add openkache
# Existing uv virtual environment:
uv pip install openkache
# Poetry
poetry add openkache
# PDM
pdm add openkache
# Pipenv
pipenv install openkache
Published wheels support Linux x86_64/ARM64, macOS x86_64/ARM64, and Windows
x86_64/ARM64. Linux wheels use the manylinux_2_38 policy tag; macOS and
Windows tags come from their native Python packaging toolchain. Other
Rust-supported targets can install from the source distribution.
The native Rust adapter supports Linux, macOS, and Windows on Rust-supported
host architectures, including ARM64. Building from source requires Python,
Rust 1.85 or newer, and the platform's normal C linker. The package selects
.so, .dylib, or .dll at import time and does not assume Linux.
On Windows checkouts, run the generator from PowerShell:
$env:OPENKACHE_GENERATION_TARGET = "python"
..\generate.ts
Quick start
The example below assumes a local OpenKache server at 127.0.0.1:4433.
from openkache import Client
client = Client.connect("127.0.0.1:4433")
print(client.set("greeting", "hello")) # -> created
print(client.get("greeting")) # -> hello
print(client.delete("greeting")) # -> True
client.close()
set returns SetOutcome.CREATED for a new key,
get returns the value directly (None when the key is absent), and delete
returns True when a value was removed.
The example uses the local development TLS profile, which does not verify the server certificate. Use it only with a local development server.
Reference
Client.connect(address)
Opens a connection and returns a Client.
- Input: a non-empty
host:portstring. IPv6 endpoints use[host]:port. - Returns:
Client. - Raises:
OpenKacheErrorwhen the connection cannot be opened.
client = Client.connect("127.0.0.1:4433")
Client and OpenKacheClient refer to the same class.
client.get(key)
Reads one value as a native Python value by default.
- Input: a UTF-8
str, signed 64-bitint, or bytes-like value (bytes,bytearray, ormemoryview). - Returns: the decoded value, or
Nonewhen the key is absent. StoredNoneand undefined values also returnNone, matching ordinary Python cache APIs. - Raises:
OpenKacheValueErrorfor an invalid key, an ambiguous native map, or a value that cannot be projected to Python;OpenKacheErrorfor connection or server failures.
print(client.get("greeting")) # -> "hello"
Use representation="lossless" when the exact value model matters:
exact = client.get("greeting", representation="lossless")
print(exact) # -> TextStringValue(value='hello')
Native reads map integers to int, floats to float, bytes to bytes,
arrays to list, and maps to dict when their keys remain distinct under
Python equality. A stored None or undefined value returns None, just like
an absent key. Use the lossless representation for the distinction between
Null and Undefined, float width/raw bits, or model-distinct map keys such
as True and 1.
client.set(key, value)
Stores one value, replacing any existing value for the key.
- Input: the same key types accepted by
get, plus a native or lossless structured value. - Returns:
SetOutcome.CREATEDfor a new key orSetOutcome.REPLACEDfor an existing key. - Raises:
OpenKacheValueErrorfor an invalid key or value andOpenKacheErrorfor connection or server failures.
outcome = client.set("greeting", "hello")
# outcome is SetOutcome.CREATED or SetOutcome.REPLACED
client.delete(key)
Deletes one key. Deleting a missing key is safe.
- Input: a key accepted by
get. - Returns:
Truewhen a value was removed, orFalsewhen no value existed. - Raises:
OpenKacheValueErrorfor an invalid key andOpenKacheErrorfor connection or server failures.
removed = client.delete("greeting")
if removed:
print("deleted")
client.close()
Closes the connection and returns None. Calling it more than once is safe.
client.close()
The client also supports with Client.connect(address), which closes the
connection automatically when the block exits.
Keys
Keys are typed. Use:
strfor UTF-8 text keys;intfor signed 64-bit integer keys;bytes,bytearray, ormemoryviewfor exact byte keys.
client.get("text-key")
client.get(42)
client.get(b"bytes-key")
Values
The client converts common Python values to structured values:
Nonebecomes Null.boolbecomes Boolean.intbecomes an exact Integer.floatbecomes an IEEE-754 binary64 Float.strbecomes UTF-8 TextString.bytes,bytearray, andmemoryviewbecome Bytes.listandtuplebecome Array.dictbecomes Map.
client.set("profile", {"name": "Ada", "active": True})
Use the lossless model when the exact representation matters:
UNDEFINED/UndefinedValue, IntegerValue, FloatValue,
ByteStringValue, TextStringValue, ArrayValue, and MapValue.
The short names Undefined, Integer, Float, ByteString, TextString,
Array, Map, and Value are compatibility aliases.
Value helpers
to_value(value, limits=None)converts a native Python value to the lossless model.encode_value(value, limits=None)returns one encodedStructuredValue-CBOR-v1item asbytes.decode_value(data, limits=None)decodes one complete item frombytes-like input.model_equal(left, right)compares model values without treatingTrueand1as equal.to_native(value)projects a decoded lossless value to the native representation used byclient.get(..., representation="native").ValueLimitsbounds encoded bytes, nesting depth, item count, and integer magnitude.
from openkache import decode_value, encode_value, model_equal, to_value
encoded = encode_value({"count": 1})
decoded = decode_value(encoded)
assert model_equal(decoded, to_value({"count": 1}))
StructuredValueError reports conversion, encoding, decoding, and resource
limit failures. Its kind property is a ValueErrorKind.
Errors
OpenKacheError— connection, protocol, server, or operation failure.OpenKacheValueError— invalid key or value supplied by the caller.OpenKacheUnknownMutationError— a mutation may have reached the server without a confirmed result; do not replay it automatically.OpenKacheIncompatibleServerError— the server returned an outcome that this client does not support.StructuredValueError— invalid structured-value data or resource limits.
Strings must contain well-formed Unicode. Unpaired UTF-16 surrogate code units are rejected.
More information
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 openkache-0.1.3.tar.gz.
File metadata
- Download URL: openkache-0.1.3.tar.gz
- Upload date:
- Size: 518.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36e7c84752997df31cc86882ceb335f4c68775bace0f6996fe11503adaeeac10
|
|
| MD5 |
a3a6081ec3cdb7f73ab9bb78b096a8b1
|
|
| BLAKE2b-256 |
d08118649e6f5b31c3efadfdd8423e4dc71ee2be005bd458d099d7a0fb8bd9ae
|
Provenance
The following attestation bundles were made for openkache-0.1.3.tar.gz:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3.tar.gz -
Subject digest:
36e7c84752997df31cc86882ceb335f4c68775bace0f6996fe11503adaeeac10 - Sigstore transparency entry: 2596783012
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-win_arm64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-win_arm64.whl
- Upload date:
- Size: 3.3 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdcb8a38140bcd652a81c6005d4b511a457ab72cd4898c4891c7c2f8d8e3b0b6
|
|
| MD5 |
6a4002742d98316b045e8a277f529ba8
|
|
| BLAKE2b-256 |
60f1e6bb7bde51684569d4e85579f36d8e656bf1193bdac9ae87983a0b7cc10d
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-win_arm64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-win_arm64.whl -
Subject digest:
bdcb8a38140bcd652a81c6005d4b511a457ab72cd4898c4891c7c2f8d8e3b0b6 - Sigstore transparency entry: 2596783260
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-win_amd64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-win_amd64.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2ebf50faecdd53ab932756f1e961448b91d650b404ff07dbcae565050c4d38b
|
|
| MD5 |
21771fedbe6e21b072138fd4d4fe865d
|
|
| BLAKE2b-256 |
393fb6bb51d7746f18bce0846d7a6cec1f7315381af4af489dc74f8d35aacd94
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-win_amd64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-win_amd64.whl -
Subject digest:
a2ebf50faecdd53ab932756f1e961448b91d650b404ff07dbcae565050c4d38b - Sigstore transparency entry: 2596783362
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: Python 3, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c70c8d923a318af7615e9067153541857960eb3030e684d174fee63aba86d42c
|
|
| MD5 |
a98eb278c2327c1221b713ee1dc0c776
|
|
| BLAKE2b-256 |
8c96c2922c91f9bf0838a9780082f61d52d51efe1539d1337dd2b8bd8246dcf9
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-manylinux_2_38_x86_64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-manylinux_2_38_x86_64.whl -
Subject digest:
c70c8d923a318af7615e9067153541857960eb3030e684d174fee63aba86d42c - Sigstore transparency entry: 2596783564
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-manylinux_2_38_aarch64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-manylinux_2_38_aarch64.whl
- Upload date:
- Size: 3.9 MB
- Tags: Python 3, manylinux: glibc 2.38+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c16dc6ff1e0fde2c32990d8c7c1a4e3eca8005386c08c8ed5140f7ba856a50b9
|
|
| MD5 |
b5e5a11690654e747ab556fb7875c30b
|
|
| BLAKE2b-256 |
c2f22946a80b71c058465f454808964842a638d9214d0796a3897f7fb0be3371
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-manylinux_2_38_aarch64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-manylinux_2_38_aarch64.whl -
Subject digest:
c16dc6ff1e0fde2c32990d8c7c1a4e3eca8005386c08c8ed5140f7ba856a50b9 - Sigstore transparency entry: 2596783453
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5aab9553a55fa595ce887a58efc4bf2ec3cbfaa9ecf29da30ea7faab5bd68d5e
|
|
| MD5 |
dfabfd85223bf63a7a763cee2426bd1c
|
|
| BLAKE2b-256 |
ee13769e57b9f1c96f36c028420724da2e255a89ca0806325bc7674c727765ef
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-macosx_11_0_arm64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-macosx_11_0_arm64.whl -
Subject digest:
5aab9553a55fa595ce887a58efc4bf2ec3cbfaa9ecf29da30ea7faab5bd68d5e - Sigstore transparency entry: 2596783101
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openkache-0.1.3-py3-none-macosx_10_13_x86_64.whl.
File metadata
- Download URL: openkache-0.1.3-py3-none-macosx_10_13_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: Python 3, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac4c7873925dc6a634c47bb3ec69e47d4f67ca918aee97c3be126d8a8a632542
|
|
| MD5 |
037e4c0cf4f0039c3b8d1200b99546c4
|
|
| BLAKE2b-256 |
e15c42933d5ab109d42d41f02738c1e5c86dc1f270e638f065e668664feca862
|
Provenance
The following attestation bundles were made for openkache-0.1.3-py3-none-macosx_10_13_x86_64.whl:
Publisher:
publish-pypi.yml on openkache/openkache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openkache-0.1.3-py3-none-macosx_10_13_x86_64.whl -
Subject digest:
ac4c7873925dc6a634c47bb3ec69e47d4f67ca918aee97c3be126d8a8a632542 - Sigstore transparency entry: 2596783191
- Sigstore integration time:
-
Permalink:
openkache/openkache@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/openkache
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@b96dc8562c808d420c42c2f56e026ff8548cc1c4 -
Trigger Event:
workflow_dispatch
-
Statement type: