Examples of how to use these APIs are included with your
distribution. See the <package>/examples
directory.
hello.c
shows basic API usage to a store that
does not require authentication. hello_secured.c
shows API usage when working with a secure store.
At a high level, to use this library:
Initialize the Java Native Interface framework (JNI) using kv_create_jni_impl().
Create a store configuration using kv_create_config().
If you are using a store that requires authentication, define the security properties and the authentication credentials. You define the security properties using kv_create_properties(), kv_set_property(), and kv_config_set_security_properties(). You create authentication credentials using kv_create_password_credentials().
Open a handle to the store using kv_open_store() or kv_open_store_login().
Perform data read and write operations using a variety of functions which are described in Data Operation Functions . Note that these functions will sometimes require durability and consistency structures and key/value structures. Functions used to create and manage these types of structures are described in Durability and Consistency Functions and Key/Value Pair Management Functions .
If you are operating against a store that requires
authentication, be prepared to handle
KV_AUTH_FAILURE
errors. When you see
these, you should reauthenticate using kv_store_login().
You are also strongly recommended to use the Avro data type for storage of your store's values. Strictly speaking, Avro usage is optional at this time, but in order to take advantage of future features, it will be required. The Avro functions provided by this library are described in Avro Functions .
Once you are done accessing the store, close your store handle using kv_close_store(). If you logged the handle into the store, this will log your handle out.
Release your store configuration structure using kv_release_config().
Release your JNI implementation using kv_release_impl().
Notice that in the above process, you allocate and initialize structures using some kind of a creation function, and you are then responsible for releasing those structures using some kind of a release function. This pattern repeats with few exceptions throughout the API. For example, to create a key, you use kv_create_key() and to release it you use kv_release_key(). In all such cases, you are responsible for releasing resources that you acquire through the use of these APIs.