photoncloud-monorepo/specifications/flaredb/003-kvs-consistency/contracts/kv_cas.md

907 B

KvCas contracts (strong consistency)

CompareAndSwap

  • RPC: kvrpc.KvCas/CompareAndSwap
  • Request:
    • namespace: string (empty => default)
    • key: bytes
    • value: bytes
    • expected_version: uint64
  • Response:
    • success: bool
    • current_version: uint64
    • new_version: uint64
  • Semantics:
    • Allowed only for strong namespaces; returns FailedPrecondition otherwise or when not leader (redirect required).
    • Proposes via Raft; state machine applies with LWW timestamp wrapper.

Get

  • RPC: kvrpc.KvCas/Get
  • Request:
    • namespace: string (empty => default)
    • key: bytes
  • Response:
    • found: bool
    • value: bytes
    • version: uint64
  • Semantics:
    • Allowed only for strong namespaces; returns FailedPrecondition if not leader.
    • Reads versioned value (timestamp-prefixed) and returns decoded value plus version.