cliffracer-kv
NATS JetStream Key-Value and Object Store integration extension for Cliffracer services.
Overview
cliffracer-kv provides NATS Key-Value and Object Store integration for Cliffracer services:
- Service Extension (
KvExtension): Declaratively bound toself.kvon your service. - Bucket Auto-Provisioning: Automatic creation of KV buckets and Object Stores with configurable options.
- Bucket-Level TTL: Direct support for bucket-level TTL configurations (
ttlparameter passed to JetStream bucket creation). - Serialization: Automatic serialization and deserialization for Pydantic models, JSON dictionaries, lists, strings, and raw bytes.
- Optimistic Concurrency: Supports revision-based updates and optimistic concurrency control.
- Object Store Support: Support for storing, retrieving, deleting, and listing large objects via NATS ObjectStore.
Installation
uv add cliffracer-kv
Usage
from pydantic import BaseModel
from cliffracer import CliffracerService
from cliffracer_kv import KvExtension, BucketConfig
class UserProfile(BaseModel):
name: str
email: str
class UserService(CliffracerService):
kv = KvExtension(
buckets=[
BucketConfig(name="profiles", ttl=3600),
"sessions",
],
bucket_ttls={"sessions": 86400},
object_stores=["media-assets"],
)
async def save_profile(self, user_id: str, profile: UserProfile):
revision = await self.kv.put("profiles", user_id, profile)
return {"saved": True, "revision": revision}
async def get_profile(self, user_id: str) -> UserProfile | None:
return await self.kv.get("profiles", user_id, as_type=UserProfile)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 cliffracer_kv-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cliffracer_kv-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffc39397967b3430dd9358e53473d3754bcd0a8dbeda1b6b742ff1297ce73c23
|
|
| MD5 |
fdacb7594d8772f4249897ea3290b984
|
|
| BLAKE2b-256 |
b18fed2a80522e168c575346ec3f47fede7a1a16f8b85b32ed6837bed5a914d1
|