Skip to main content

Key-value operations

Create a key-value pair​

Keys can be created with the following command:

./rostore-cli put-key -c container-name -k key -i value-file [--ttl pt10m] [--ver 1] [--record-options options] [-p profile]

Enter container-name and key and provide an existing value-file with the value. The value-file may contain any binary content.

In case the key should only be created temporarily a ttl can be provided. After the expiration of the provided duration these keys become inactive and will eventually be deleted from the storage.

In case version (option -ver) is provided, the key is created versioned. If no version is provided the key is created unversioned. Unversioned keys can be overritten without knowing the latest version of the key. If the key is created with the version 1, the current stored version is returned - 2. This version should be provided in case the value of this key should be overriden.

Every put operation on the versioned key should provide the version of the key as the previous operation has returned. To show the version the -v (verbose) option can be provided.

There is also a way to provide additional operations to the command: --record-options. It might contain the following literals: ONLY_INSERT,ONLY_REPLACE,OVERRIDE_VERSION or a list of them separated by the comma.

OptionDescription
ONLY_INSERTWill only allow to create a key-value if the key is not available already, otherwise an error will be communicated
ONLY_REPLACEWill only allow to execute the command on the keys if the key already available in the storage, otherwise an error will be communicated
OVERRIDE_VERSIONWill use the provided version (-ver option) and override it for the given key, without considering the versioning sequence

Get a key's value​

Keys can be read with the following command:

./rostore-cli get-key -c container-name -k key [-o value-file] [-p profile]

Operation prints out the value associated with the key into the console. For binary data an option -o with a value-file can be provided. In the later case the content will be written down to the provided file.

An additional option -v (verbose) would provide even more information about the key-value.

List container's keys​

To list all the existing containers in the rostore storage the following command can be executed:

./rostore-cli list-container-keys -c container-name [--continuation-key key] [--start-with-key prefix] [-p profile]

The command will only return only a portion of keys. The keys will be returned in the order of shards, and keys within the shards will be returned sorted binary, assuming keys are binary representation of utf-8 string.

If a continuation of listing is required - an optional parameter --continuation-key can be provided. This parameter should be set to the last key returned in the previous portion.

If only keys started with a specific prefix is needed, an optional --start-with-key option can be used.