TTL
Expire keys automatically using Combee KV TTL.
since 0.1.0-beta
Combee KV supports time-based expiry. Set a TTL when writing, or change it later with EXPIRE.
Set a TTL on write
# Expires in 300 seconds
curl -X PUT https://api.combee.cloud/v1/databases/2f1c4a0e-8d3b-4b2a-9f7e-1c2d3e4f5a6b/kv/session:user:1 \
-H "x-api-key: $COMBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": "{\"name\": \"Ada\"}", "ttl_seconds": 300}'Inspect remaining time
ttl() returns the key state:
# Remaining seconds; -1 = persistent; null = missing
curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-8d3b-4b2a-9f7e-1c2d3e4f5a6b/kv/ops/ttl \
-H "x-api-key: $COMBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"keys": ["session:user:1"]}'
# → [299]Change or remove the TTL
# Reset to 60s
curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-8d3b-4b2a-9f7e-1c2d3e4f5a6b/kv/ops/expire \
-H "x-api-key: $COMBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "session:user:1", "ttl_seconds": 60}'
# Remove TTL (keep forever)
curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-8d3b-4b2a-9f7e-1c2d3e4f5a6b/kv/ops/expire \
-H "x-api-key: $COMBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "session:user:1"}'Expired keys are removed lazily — they stop being readable immediately and are garbage-collected in the background.