kvstore

Name

kvstore -- Access the manager configuration's key value store

Synopsis


package require kvstore

kvstore::create db key value
kvstore::modify db key new-value
kvstore::remove db key
set value [kvstore::get    db key]
set keys [kvstore::listKeys db]
set kvdict [dvstore::listAll db]

      

DESCRIPTION

The key value store API, kvstore, provides access to the key value store table in a manager configuration database.

A key value store can be thought of as an array whose keys are strings. The manager key value store is string valued. Associated with each key is a string value. A kvstore package provides the abiliy directly access the key value store in the configuration SQLite3 database file.

Using the API, you can create a new key/value pair. Your application can read existing keys and modify their values. Finally, you can also remove an existing key/value pair from the store.

PUBLIC COMMANDS

In the list of public entries that follow, The db parameter is an SQLite3 database connection command that's associated with the manager configuration database that contains the kvstore you wish to use.

kvstore::create db key value

Creates a new entry in the key value store with key named key and an initial value value

If there is already a key named key in the database, an error is signalled.

kvstore::modify db key new-value

Modifies the value of the existing key setting it to new-value. If key does not yet exist, an error will be signalled.

kvstore::remove db key

Removes the existing key from the key value store. If key was not yet defined, an error is signalled.

kvstore::get db key

Returns the value associated with the key. If the key is not defined, an error is signalled.

kvstore::listKeys db

Lists the keys defined in the key value store. It is not an error to invoke this when no keys are defined. If that is the case an empty list is returned.

dvstore::listAll db

Returns a dict whose keys are all of the defined keys in the key value store and whose values are the values of those keys.