NATS C Client with JetStream and Streaming support  3.9.1
The nats.io C Client, Supported by Synadia Communications Inc.
KeyValue store management

Functions

NATS_EXTERN natsStatus kvConfig_Init (kvConfig *cfg)
 Initializes a KeyValue configuration structure. More...
 
NATS_EXTERN natsStatus js_CreateKeyValue (kvStore **new_kv, jsCtx *js, kvConfig *cfg)
 Creates a KeyValue store with a given configuration. More...
 
NATS_EXTERN natsStatus js_KeyValue (kvStore **new_kv, jsCtx *js, const char *bucket)
 Looks-up and binds to an existing KeyValue store. More...
 
NATS_EXTERN natsStatus js_DeleteKeyValue (jsCtx *js, const char *bucket)
 Deletes a KeyValue store. More...
 
NATS_EXTERN void kvStore_Destroy (kvStore *kv)
 Destroys a KeyValue store object. More...
 

Detailed Description

These functions allow to create, get or delete a KeyValue store.

Warning
EXPERIMENTAL FEATURE! We reserve the right to change the API without necessarily bumping the major version of the library.

Function Documentation

◆ kvConfig_Init()

NATS_EXTERN natsStatus kvConfig_Init ( kvConfig cfg)

Use this before setting specific kvConfig options and passing it to js_CreateKeyValue.

See also
js_CreateKeyValue
Parameters
cfgthe pointer to the stack variable kvConfig to initialize.

◆ js_CreateKeyValue()

NATS_EXTERN natsStatus js_CreateKeyValue ( kvStore **  new_kv,
jsCtx js,
kvConfig cfg 
)

Creates a KeyValue store with a given configuration.

Bucket names are restricted to this set of characters: A-Z, a-z, 0-9, _ and -.

Note
The return kvStore object needs to be destroyed using kvStore_Destroy when no longer needed to free allocated memory. This is different from deleting a KeyValue store from the server using the js_DeleteKeyValue API.
Parameters
new_kvthe location where to store the newly created kvStore object.
jsthe pointer to the jsCtx object.
cfgthe pointer to the kvConfig configuration information used to create the kvStore object.

◆ js_KeyValue()

NATS_EXTERN natsStatus js_KeyValue ( kvStore **  new_kv,
jsCtx js,
const char *  bucket 
)

This call is when the user wants to use an existing KeyValue store. If the store does not already exists, an error is returned.

Bucket names are restricted to this set of characters: A-Z, a-z, 0-9, _ and -.

Note
The return kvStore object needs to be destroyed using kvStore_Destroy when no longer needed to free allocated memory. This is different from deleting a KeyValue store from the server using the js_DeleteKeyValue API.
Parameters
new_kvthe location where to store the newly created kvStore object.
jsthe pointer to the jsCtx object.
bucketthe name of the bucket of the existing KeyValue store.

◆ js_DeleteKeyValue()

NATS_EXTERN natsStatus js_DeleteKeyValue ( jsCtx js,
const char *  bucket 
)

This will delete the KeyValue store with the bucket name.

Bucket names are restricted to this set of characters: A-Z, a-z, 0-9, _ and -.

Parameters
jsthe pointer to the jsCtx object.
bucketthe name of the bucket of the existing KeyValue store.

◆ kvStore_Destroy()

NATS_EXTERN void kvStore_Destroy ( kvStore kv)

This will simply free memory resources in the library for this kvStore, but does not delete the KeyValue store in the server.

Parameters
kvthe pointer to the kvStore object.