(cas conn k v rev)(cas conn bucket-name k v rev)Compare and swap. Sets the value of k to v, only if the current revision is
still rev.
Returns the new revision number for the key.
(cas conn :bucket/key "val" 32)
(cas conn "bucket" "key" "val" 32)
Compare and swap. Sets the value of `k` to `v`, only if the current revision is still `rev`. Returns the new revision number for the key. ``` (cas conn :bucket/key "val" 32) (cas conn "bucket" "key" "val" 32) ```
(configure conn key-value-options)Re-configure the KeyValue management instance. Returns a new conn with the
new configuration, does not change the original conn.
key-value-options is a map of:
:nats.kv/stream-options - JetStream configuration, see
nats.stream/configure for details.:nats.kv/domain:nats.kv/prefix:nats.kv/request-timeoutRe-configure the KeyValue management instance. Returns a new `conn` with the new configuration, does not change the original `conn`. `key-value-options` is a map of: - `:nats.kv/stream-options` - JetStream configuration, see `nats.stream/configure` for details. - `:nats.kv/domain` - `:nats.kv/prefix` - `:nats.kv/request-timeout`
(create-bucket conn config)Create a key/value bucket. config is a map of:
:nats.kv/bucket-name:nats.kv/description:nats.kv/replicas:nats.kv/storage-type - See nats.stream/storage-types:nats.kv/ttl - Number of milliseconds, or a java.time.Duration:nats.kv/compression?:nats.kv/max-bucket-size:nats.kv/max-history-per-key:nats.kv/max-value-size:nats.kv/metadata - A map of {string|keyword string}:nats.kv/mirror - A map, see below:nats.kv/placement - A map, see below:nats.kv/republish - A map, see below:nats.kv/sources - A collection of sources, see belowKeys in the :nats.kv/mirror map and entries in the :nats.kv/sources collection:
:nats.source/domain:nats.source/external:nats.source/filter-subject:nats.source/name:nats.source/source-name:nats.source/start-seq:nats.source/start-time:nats.source/subject-transforms:nats.kv/placement map keys:
:nats.placement/cluster:nats.placement/tags:nats.kv/republish map keys:
:nats.republish/destination:nats.republish/headers-only?:nats.republish/sourceCreate a key/value bucket. `config` is a map of:
- `:nats.kv/bucket-name`
- `:nats.kv/description`
- `:nats.kv/replicas`
- `:nats.kv/storage-type` - See `nats.stream/storage-types`
- `:nats.kv/ttl` - Number of milliseconds, or a `java.time.Duration`
- `:nats.kv/compression?`
- `:nats.kv/max-bucket-size`
- `:nats.kv/max-history-per-key`
- `:nats.kv/max-value-size`
- `:nats.kv/metadata` - A map of {string|keyword string}
- `:nats.kv/mirror` - A map, see below
- `:nats.kv/placement` - A map, see below
- `:nats.kv/republish` - A map, see below
- `:nats.kv/sources` - A collection of sources, see below
Keys in the `:nats.kv/mirror` map and entries in the `:nats.kv/sources` collection:
- `:nats.source/domain`
- `:nats.source/external`
- `:nats.source/filter-subject`
- `:nats.source/name`
- `:nats.source/source-name`
- `:nats.source/start-seq`
- `:nats.source/start-time`
- `:nats.source/subject-transforms`
`:nats.kv/placement` map keys:
- `:nats.placement/cluster`
- `:nats.placement/tags`
`:nats.kv/republish` map keys:
- `:nats.republish/destination`
- `:nats.republish/headers-only?`
- `:nats.republish/source`(delete conn k)(delete conn k expected-rev)(delete conn bucket-name k expected-rev)Delete the value at key k. When providing the optional expected-rev, only
delete the value if the current revision is still expected-rev.
Returns the new revision number for the key.
(delete conn :bucket/key)
;; Delete specific revision
(delete conn :bucket/key 32)
(delete conn "bucket" "key" 32)
;; Explicitly name bucket and key without specifying revision
(delete conn "bucket" "key" nil)
Delete the value at key `k`. When providing the optional `expected-rev`, only delete the value if the current revision is still `expected-rev`. Returns the new revision number for the key. ``` (delete conn :bucket/key) ;; Delete specific revision (delete conn :bucket/key 32) (delete conn "bucket" "key" 32) ;; Explicitly name bucket and key without specifying revision (delete conn "bucket" "key" nil) ```
(delete-bucket conn bucket-name)Delete a key/value bucket
Delete a key/value bucket
(get conn k)(get conn k rev)(get conn bucket-name k rev)Get the entry for key k. Returns the version specified by rev, or the
current one.
(get conn :bucket/key)
(get conn :bucket/key 42)
(get conn "bucket" "key" 42)
Get the entry for key `k`. Returns the version specified by `rev`, or the current one. ``` (get conn :bucket/key) (get conn :bucket/key 42) (get conn "bucket" "key" 42) ```
(get-history conn k)(get-history conn bucket-name k)Returns all revisions of the key k.
(get-history conn :bucket/key)
(get-history conn "bucket" "key")
Returns all revisions of the key `k`. ``` (get-history conn :bucket/key) (get-history conn "bucket" "key") ```
(get-keys conn bucket-name)Return a set of all the keys in the bucket as strings
Return a set of all the keys in the bucket as strings
(get-value conn k)(get-value conn k rev)(get-value conn bucket-name k rev)Get the value for key k. Returns the version specified by rev, or the
current one.
(get-value conn :bucket/key)
(get-value conn :bucket/key 42)
(get-value conn "bucket" "key" 42)
Get the value for key `k`. Returns the version specified by `rev`, or the current one. ``` (get-value conn :bucket/key) (get-value conn :bucket/key 42) (get-value conn "bucket" "key" 42) ```
Available key value operations:
:nats.kv-operation/delete:nats.kv-operation/purge:nats.kv-operation/putAvailable key value operations: - `:nats.kv-operation/delete` - `:nats.kv-operation/purge` - `:nats.kv-operation/put`
(purge conn k)(purge conn k expected-rev)(purge conn bucket-name k expected-rev)Purge all history for a single key, optionally specify the expected current revision.
(purge conn :bucket/key)
(purge conn :bucket/key 23)
(purge conn "bucket" "key" 23)
Purge all history for a single key, optionally specify the expected current revision. ``` (purge conn :bucket/key) (purge conn :bucket/key 23) (purge conn "bucket" "key" 23) ```
(purge-deleted conn bucket-name & [{:keys [delete-marker-threshold]}])Purges history for deleted keys in bucket-name
Purges history for deleted keys in `bucket-name`
(put conn k v)(put conn bucket-name k v)Put a key in the bucket. v can be either a byte array or any serializable
Clojure value.
Supports two arities:
(put conn :bucket/key v)
(put conn "bucket" "key" v)
Put a key in the bucket. `v` can be either a byte array or any serializable Clojure value. Supports two arities: ``` (put conn :bucket/key v) (put conn "bucket" "key" v) ```
(update-bucket conn config)Update a key/value bucket. See create-bucket for config details.
Update a key/value bucket. See `create-bucket` for `config` details.
(watch conn bucket-name watcher)(watch conn bucket-name watcher watch-opts)(watch conn bucket-name subjects watcher watch-opts)(watch conn
bucket-name
subjects
from-rev
{:keys [watch end-of-data consumer-name-prefix]}
watch-opts)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |