Edit this page on GitHub

Home > docs > plugins > Key Value Task

Key Value Task

The key value kv task provides access to the server’s simple string key-value store. All data is project-scoped e.a. processes only see the values created by processes of the same project.

This task is provided automatically by Concord.


Setting a Value

Setting a string value:

- ${kv.putString("myKey", "myValue")}

Setting an integer (64-bit long) value:

- ${kv.putLong("myKey", 1234)}

Retrieving a Value

Using the OUT syntax of expressions:

- expr: ${kv.getString("myKey")}
  out: myVar

- log: "I've got ${myVar}"

Using the context:

- ${context.setVariable("myVar", kv.getString("myKey"))}
- log: "I've got ${myVar}"

In scripts:

- script: groovy
  body: |
    def kv = tasks.get("kv");

    def id = kv.inc("idSeq");
    println("I've got {id}");

Integer values can be retrieved in the same way:

- log: "I've got ${kv.getLong('myKey')}"

Removing a Value

- ${kv.remove("myVar")}
- if: ${kv.getString("myVar") == null}
    - log: "Ciao, myVar! You won't be missed."

Incrementing a Value

This can be used as a simple sequence number generator.

- expr: ${kv.inc("idSeq")}
  out: myId
- log: "We got an ID: ${myId}"

Warning: the existing string values can’t be incremented.