KV
Create a namespace, then write and read a value.
KV stores bytes under keys, grouped in a namespace you create. A value can expire on a timer, a counter can be incremented atomically, and a write can be made conditional. Beyond plain values, a key can hold a hash, a list or a sorted set.
API access
Use https://api.sylphx.com/v1 to manage namespaces and read or write values.
A key needs the data:write scope to write and data:read to read. Every
call that changes data carries a Sylphx-Effect-Id header, 1 to 128 characters
of letters, digits and . _ : -, new for each new intent and reused on a
retry: Data then applies a retried write once. The @sylphx/sdk client sets it
for you.
Create a namespace
Create a KV namespace in your environment.
Set default_ttl in its spec to expire values that do not specify a TTL.
Wait for creation to finish, then use the namespace ID in each value request.
The examples below use kv-demo.
Write and read a value
curl -X PUT "https://api.sylphx.com/v1/kv/kv-demo/greeting" \
-H "Authorization: Bearer $SYLPHX_API_KEY" \
-H "Content-Type: application/json" \
-H "Sylphx-Effect-Id: put-greeting-1" \
-d '{"namespaceId": "kv-demo", "key": "greeting", "value": "aGVsbG8=", "ttlSeconds": "60"}'
curl "https://api.sylphx.com/v1/kv/kv-demo/greeting" \
-H "Authorization: Bearer $SYLPHX_API_KEY"The answer is the stored entry: the value, its sha256, a version that
increases on every write, and expiresAtUnixMs (0 never expires). A missing or
expired key answers 404.
What you can do
| Need | Call |
|---|---|
| Set a lifetime | ttlSeconds on the write; 0 never expires; expire changes it later. |
| Write only if the key is absent or present | nx or xx on the write. |
| Write only if nobody else wrote since you read | expectedVersion on the write. |
| Count | increment adds delta (default 1) to an integer value. |
| Read many | get_many reads up to 1000 keys in one call. |
| Group fields under one key | hash_set, hash_get, hash_get_all, hash_get_many. |
| Queue or stack | list_push, list_range, list_pop, list_length. |
| Rank | zset_add, zset_range, zset_score, zset_length. |
| Walk keys | list in key order, or scan with a glob and a cursor. |
Each is one method of the KV collection, with its request, response and examples.
KV is a key-value store. It does not provide a rate-limiter helper: build one
from increment and a TTL.