Skip to main content

Python client for NATS KeyValue Store

Project description

NATS Key-Value

A Python client for the NATS Key-Value store, built on JetStream.

Features

  • Create, update, and delete buckets
  • Put, get, create, update, delete, and purge keys
  • Optimistic concurrency via revisions
  • Per-key history
  • Per-key TTL
  • Watch for changes with key pattern filters
  • List keys and bucket statuses

Installation

pip install nats-key-value

Requires Python 3.13+ and a NATS server with JetStream enabled.

Usage

import asyncio
from nats.client import connect
from nats.jetstream import new as new_jetstream
from nats.key_value import KeyValueConfig, create_or_update_key_value

async def main():
    client = await connect("nats://localhost:4222")
    js = new_jetstream(client)

    kv = await create_or_update_key_value(js, KeyValueConfig(bucket="config"))

    await kv.put("greeting", b"Hello World!")

    entry = await kv.get("greeting")
    print(f"{entry.key} = {entry.value.decode()} (revision {entry.revision})")

    await kv.delete("greeting")

    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

License

MIT

Contributing

Contributions welcome. Submit a Pull Request on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nats_key_value-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nats_key_value-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file nats_key_value-0.1.0.tar.gz.

File metadata

  • Download URL: nats_key_value-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nats_key_value-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c4a3adfc213815748c6c9191b5711b827584b994bce9d76689b8eb4052d85ba
MD5 ebe59e9970218e72eb25a09a2a26fcbe
BLAKE2b-256 f626007ab728767a4d465e54c31602b2fc1900a92c24e9954a4446b07079f0dc

See more details on using hashes here.

File details

Details for the file nats_key_value-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nats_key_value-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nats_key_value-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 342ff16400de934a96c14c4024ef3548cd665342185f73abf67d3778748b9d0f
MD5 a022cad1bfc5c66e5567c9f437599af4
BLAKE2b-256 b2c6e4730da7a83f8857832335ea46c4e459b5379c79ad3ac943c2d94f0cb52d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page