Key Value Store

Key-Value Store usage

Pipeless contains a key-value store that helps you in the cases when you need to share data between the execution of different frames or between the execution of different hooks within a stage.

💡

Note that stages are independent, so a stage cannot access the KV pairs set by a different stage.

Setting and getting pairs from the KV store

To interact with the KV store you can use some functions that are embedded into your code and ready to use, so you don't even need to import them.

Setting a pair

To set a new pair you can call the function pipeless_kvs_set providing the key and the value:

pipeless_kvs_set("my_key", "My value")

The set function converts any value into string before inserting it into the store. And the get function returns always a string.

Getting a pair

To get a pair from the store you can call the function pipeless_kvs_get providing the key to fetch.

Due to the parallelized nature of Pipeless, you must always check the value obtained from the get function. When the key requested has not been set it will return an empty string. This may happen when your code tries to get data from a previous frame that is being processed at the same time.

value = pipeless_kvs_get("my_key")
if not value:
   printf("There is no key set")
else
   printf(f"Obtained value: {value}")