Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m3s
event/backend/log/kv/api over one injected backend protocol (mem default). log: append/read/read-from, sequential per-stream seq, stream isolation. kv: get/put/delete/has?/keys/get-or/update. conformance.sh + 3 suites, 28/28. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
975 B
Plaintext
27 lines
975 B
Plaintext
; persist/kv — the kv facet: current-state values, no history. For things
|
|
; whose history does NOT matter (stock counts, config, profiles, session
|
|
; blobs) and where projections materialize their read models.
|
|
; Requires: lib/persist/backend.sx.
|
|
|
|
(define persist/kv-get (fn (b key) (persist/backend-kv-get b key)))
|
|
(define
|
|
persist/kv-put
|
|
(fn (b key val) (begin (persist/backend-kv-put b key val) val)))
|
|
(define persist/kv-delete (fn (b key) (persist/backend-kv-delete b key)))
|
|
(define persist/kv-has? (fn (b key) (persist/backend-kv-has? b key)))
|
|
(define persist/kv-keys (fn (b) (persist/backend-kv-keys b)))
|
|
|
|
; get with a default when the key is absent
|
|
(define
|
|
persist/kv-get-or
|
|
(fn
|
|
(b key dflt)
|
|
(if (persist/kv-has? b key) (persist/kv-get b key) dflt)))
|
|
|
|
; read-modify-write: apply f to the current value (or dflt if absent), store result
|
|
(define
|
|
persist/kv-update
|
|
(fn
|
|
(b key dflt f)
|
|
(persist/kv-put b key (f (persist/kv-get-or b key dflt)))))
|