TTL, misses, and write retries
Applies to: CLI record operations in the public baseline and matched development SDKs. Flags for replica acknowledgments require newer builds; this guide uses local synchronization only.
Give a record an expiration
smkv --addr 127.0.0.1:7379 put session active --ttl-ms 1000
sleep 2
smkv --addr 127.0.0.1:7379 get session
echo $?
The last read returns exit code 2 for a missing or expired record. Operational failures return 1. Expiration removes logical visibility; it does not immediately return all storage bytes to the filesystem.
For SDK puts, omitting TTL means no expiration. For updates, omitting TTL preserves the existing absolute expiration. Supplying a TTL on update resets it. A zero TTL expires immediately in the Python API. To clear a row's expiration, replace it with a put without TTL.
Distinguish empty from missing
An empty byte value is a valid record. Do not infer a miss from an empty payload. Check the CLI exit code or the SDK's explicit not_found result.
from smkv import Client, SmkvError
with Client("127.0.0.1:7379") as client:
try:
value = client.get(b"session")
except SmkvError as error:
if error.code == "not_found":
value = None
else:
raise
Treat a connection failure as an operational error rather than a cache miss unless that fallback is an explicit application policy.
Select durability per operation
smkv --addr 127.0.0.1:7379 --sync put greeting hello
--sync requests local durable storage before acknowledgment. It does not wait for an asynchronous replica. Default writes can be lost after a failure. Newer replica-acknowledgment modes need a compatible server and topology; do not assume that a flag alone creates quorum protection.
Handle an unknown outcome
A mutation can finish after the client times out. An SDK error with outcome_unknown=True means the application must reconcile before replaying it. Blind retries can reset TTL, overwrite newer content, or duplicate work in application workflows.
Use a stable record identity, bound the operation deadline, and define how your application resolves uncertainty. There is no cross-record transaction or automatic exactly-once contract. For cluster routing and client-specific retry behavior, read the SDK contracts.