class NATS::KV::Client

Defined in:

kv.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(nats : NATS::Client) #

[View source]

Instance Method Detail

def create(bucket : String, key : String, value : String | Bytes) : Int64 | Nil #

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

[View source]
def 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


[View source]
def delete(bucket : String, key : String) #

[View source]
def delete(bucket : Bucket) #

[View source]
def delete_bucket(bucket : String) #

[View source]
def get(bucket : String, key : String, ignore_deletes = false) : Entry | Nil #

Get the value associated with the current


[View source]
def get_bucket(name : String) : Bucket | Nil #

[View source]
def history(bucket : String, key : String) : Array(Entry) #

[View source]
def keys(bucket : String) : Set(String) #

Get all of the keys for the given bucket name


[View source]
def purge(bucket : String, key : String) #

[View source]
def put(bucket : String, key : String, value : String | Bytes) : Int64 #

Assign value to key in bucket.


[View source]
def set(bucket : String, key : String, value : Data) #

[View source]
def 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. 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

[View source]
def watch(bucket : String, key : String, *, ignore_deletes = false, include_history = false, &block : Entry, Watch -> ) #

[View source]