View Source nats_kv (enats v1.0.0)
Summary
Functions
Create will add the key/value pair if it does not exist. If the key already exists, ErrKeyExists will be returned.
CreateKeyValue will create a KeyValue store with the given configuration.
Delete will place a delete marker and leave all revisions. A history
of a deleted key can still be retrieved by using the History method
or a watch on the key. Delete
is a non-destructive operation and
will not remove any previous revisions from the underlying stream.
DeleteKeyValue will delete this KeyValue store.
Get returns the latest value for the key. If the key does not exist, ErrKeyNotFound will be returned.
ListKeys will return KeyLister, allowing to retrieve all keys from the key value store in a streaming fashion (on a channel).
Purge will place a delete marker and remove all previous revisions.
Only the latest revision will be preserved (with a delete marker).
Unlike Delete
, Purge is a destructive operation and will remove all
previous revisions from the underlying streams.
Put will place the new value for the key into the store. If the key does not exist, it will be created. If the key exists, the value will be updated.
SekectKeys will return KeyLister, allowing to retrieve selected keys from the key value store in a streaming fashion (on a channel).
Update will update the value if the latest revision matches. If the provided revision is not the latest, Update will return an error.
UpdateKeyValue will update an existing KeyValue store with the given configuration.
Watch for any updates to keys that match the keys argument which could include wildcards. By default, the watcher will send the latest value for each key and all future updates. Watch will send a nil entry when it has received all initial values. There are a few ways to configure the watcher
WatchAll will invoke the callback for all updates.
Types
-type config() :: #{bucket := binary(), description => binary(), max_value_size => non_neg_integer(), history => 1..64, ttl => non_neg_integer(), max_bytes => non_neg_integer(), storage => memory | file, num_replicas => 1..5, placement => nats_stream:placement(), republish => nats_stream:republish(), mirror => nats_stream:stream_source(), sources => [nats_stream:stream_source()], compression => boolean()}.
Functions
Create will add the key/value pair if it does not exist. If the key already exists, ErrKeyExists will be returned.
A key has to consist of alphanumeric characters, dashes, underscores, equal signs, and dots.
CreateKeyValue will create a KeyValue store with the given configuration.
If a KeyValue store with the same name already exists and the configuration is different, ErrBucketExists will be returned.
Delete will place a delete marker and leave all revisions. A history
of a deleted key can still be retrieved by using the History method
or a watch on the key. Delete
is a non-destructive operation and
will not remove any previous revisions from the underlying stream.
LastRevision
option can be specified to only perform delete if the
latest revision the provided one.
DeleteKeyValue will delete this KeyValue store.
If the KeyValue store with given name does not exist, ErrBucketNotFound will be returned.
Get returns the latest value for the key. If the key does not exist, ErrKeyNotFound will be returned.
ListKeys will return KeyLister, allowing to retrieve all keys from the key value store in a streaming fashion (on a channel).
Purge will place a delete marker and remove all previous revisions.
Only the latest revision will be preserved (with a delete marker).
Unlike Delete
, Purge is a destructive operation and will remove all
previous revisions from the underlying streams.
LastRevision
option can be specified to only perform purge if the
latest revision the provided one.
Put will place the new value for the key into the store. If the key does not exist, it will be created. If the key exists, the value will be updated.
A key has to consist of alphanumeric characters, dashes, underscores, equal signs, and dots.
SekectKeys will return KeyLister, allowing to retrieve selected keys from the key value store in a streaming fashion (on a channel).
Update will update the value if the latest revision matches. If the provided revision is not the latest, Update will return an error.
UpdateKeyValue will update an existing KeyValue store with the given configuration.
If a KeyValue store with the given name does not exist, ErrBucketNotFound will be returned.
Watch for any updates to keys that match the keys argument which could include wildcards. By default, the watcher will send the latest value for each key and all future updates. Watch will send a nil entry when it has received all initial values. There are a few ways to configure the watcher:
- IncludeHistory will have the key watcher send all historical values for each key (up to KeyValueMaxHistory).
- IgnoreDeletes will have the key watcher not pass any keys with delete markers.
- UpdatesOnly will have the key watcher only pass updates on values (without latest values when started).
- MetaOnly will have the key watcher retrieve only the entry meta data, not the entry value.
- ResumeFromRevision instructs the key watcher to resume from a specific revision number.
WatchAll will invoke the callback for all updates.