class NATS::KV::Client
- NATS::KV::Client
- Reference
- Object
Defined in:
kv.crConstructors
Instance Method Summary
-
#create(bucket : String, key : String, value : String | Bytes) : Int64 | Nil
Create a key in the given
bucketwith the specifiedvalue. -
#create_bucket(name : String, description : String = "", *, max_value_size : Int32 | Nil = nil, history : UInt8 | Nil = nil, ttl : Time::Span | Nil = nil, max_bytes : Int64 | Nil = nil, storage : JetStream::API::V1::StreamConfig::Storage = :file, replicas : Int32 = 1, allow_rollup : Bool = true, deny_delete : Bool = true)
https://github.com/nats-io/nats.go/blob/d7c1d78a50fc9cded3814ae7d7176fa66b73a4b0/kv.go#L295-L307
- #delete(bucket : String, key : String)
- #delete(bucket : Bucket)
- #delete_bucket(bucket : String)
-
#get(bucket : String, key : String, ignore_deletes = false) : Entry | Nil
Get the value associated with the current
- #get_bucket(name : String) : Bucket | Nil
- #history(bucket : String, key : String) : Array(Entry)
-
#keys(bucket : String) : Set(String)
Get all of the keys for the given bucket name
- #purge(bucket : String, key : String)
-
#put(bucket : String, key : String, value : String | Bytes) : Int64
Assign
valuetokeyinbucket. - #set(bucket : String, key : String, value : Data)
-
#update(bucket : String, key : String, value : String | Bytes, revision : Int) : Int64 | Nil
Update a bucket's key with the specified value only if the current value is the specified revision.
- #watch(bucket : String, key : String, *, ignore_deletes = false, include_history = false, &block : Entry, Watch -> )
Constructor Detail
Instance Method Detail
Create a key in the given bucket with the specified value. On
success, #create returns the new revision number for the key. If the
key already exists, the value will not be set and nil is returned.
if revision = kv.create("my-bucket", "my-key", "my-value")
# created
else
# key already existed and value was not set
end
https://github.com/nats-io/nats.go/blob/d7c1d78a50fc9cded3814ae7d7176fa66b73a4b0/kv.go#L295-L307
Get the value associated with the current
Assign value to key in bucket.
Update a bucket's key with the specified value only if the current value
is the specified revision. If this revision is the latest, the update is
not performed and this method returns nil.
if revision = kv.update(bucket, key, value, revision)
# updated
else
# outdated revision
end