Key-Value Store
Description
The Key-Value Store component stores and retrieves values shared across events, scenarios and processing modes. Use it to keep state that outlives a single event — for example counters, user profiles, feature flags or data handed over from one scenario to another.
Entries are grouped into namespaces. A namespace defines:
- the key name — a label describing what the key represents (e.g.
userId), - the value schema — a JSON schema all values stored in the namespace must conform to. The Designer derives the value type from this schema, so values you read and write are fully typed in scenario expressions.
Every entry has a time-to-live (TTL) and is automatically removed after that duration. The Fluss backend is the exception: its entries never expire.
The component supports two operations:
get— reads the value stored under a key; returnsnullwhen the key is absent or expired,set— writes a value under a key with the given TTL, overwriting the previous value if present.
What it is for
The main use is a handoff between processing modes. A streaming scenario computes state from events - a sliding window, an aggregate, the last value seen for a key - and writes it under that key with a TTL. A request-response scenario reads it by key and answers in milliseconds, without touching the event stream. The namespace's value schema is the contract between the two: the writer and the reader are typed against the same definition.
Exposed as an MCP tool, such a request-response scenario gives an AI agent real-time context: the agent asks for a key and gets fresh, pre-computed, typed state instead of raw events. The blog post Real-time Kafka data for AI agents with MCP walks through this pipeline end to end: purchases on a Kafka topic, a sliding window in a streaming scenario, the aggregate in a namespace with a TTL, a request-response scenario classifying it with a decision table, and the scenario published as an MCP tool the agent calls.
Beyond that handoff, the store serves the usual per-key state: counters, user profiles, feature flags, idempotency keys and lookups cached by key.
Parameters and configuration
| Name | Description |
|---|---|
| Operation | get or set. |
| Namespace | Namespace that groups keys and defines the value schema. Namespaces are created and deleted in the Key-Value Store tab. Preselected when the store has exactly one namespace; otherwise it has to be chosen. |
| Key (shown under the namespace's key name) | Unique identifier of the entry within the namespace. A null key causes a runtime error for the processed record. |
| Value | set operation only — the value to store. Its type is derived from the namespace schema and validated in the Designer. A null value causes a runtime error for the processed record. |
| TTL | set operation only — time-to-live of the entry; the entry is automatically removed after this duration. Defaults to 1 hour. Not shown for the Fluss backend. |
| Output variable name | Variable name under which the node result will be available in subsequent nodes. The node window shows it only for get. |
Returned value
| Operation | Returned value |
|---|---|
get | The stored value, typed according to the namespace schema, or null when the key is absent or its TTL has expired. |
set | A record with a single field keyExisted (Boolean) — true when the write overwrote an existing entry. The node window does not show the output variable name for set, so the result is available under the name the node already has, #output for a new node. An empty record for the Fluss backend. |
Namespaces
No namespace is created for you: before the component can be used, at least one has to be defined in the
Key-Value Store tab. Until then, the node shows that a namespace has to be defined
there first. Namespaces are created and deleted in the same tab, by users with the Core.AdminAccess permission. For each namespace, you
specify its name, key name, an optional description, and the schema of its stored values. The description says what
the namespace holds and who fills it; it is kept in the value schema as its description, next to the descriptions of
its fields. In the node, it opens the hint of the Value parameter, before the rule every value follows, and is the
hint of the namespace's field list. A description holds at most 2000 characters.
A namespace name may contain letters, digits, spaces, hyphens and underscores. Deleting a namespace removes all
entries stored in it. A namespace used by an active scenario cannot be deleted: Delete is greyed out and its
tooltip names the scenarios to stop first. A scenario counts as active in any status other than NOT_DEPLOYED,
CANCELED and FINISHED, also PROBLEM. Scenarios that are not running and fragments do not block the deletion;
the confirmation lists those scenarios, because they cannot be deployed until the namespace exists again. Only nodes
that name the namespace directly are checked, as in Used by. Only the description of an existing namespace can be changed. You cannot change its key name
or its schema: delete the namespace and create it again, which removes its entries.
The value schema is defined with the JSON schema builder: a table of fields, or JSON Schema text. Only flat schemas (no nested objects) can be defined there. The Value of a set operation can be built with the Data Mapper.
Key-Value Store management
Users with the Core.AdminAccess permission open the tab from the Key-Value Store entry in the left menu. It lists every Key-Value Store configured in
any scenario type; when there is more than one, pick it in the Store field at the top of the namespace list.
Stores with the same component ID but different backend configurations remain separate; use the scenario type
to choose the right one. Identical backend configurations are grouped across scenario types. Search
the list, open a namespace to see its description, then in tabs its key name and fields (Schema, a read-only table;
hover a field for its description) and the scenarios that use it (Used by), to change its description (the pencil next to it), to Clone it (a new namespace with the same key name,
description and fields) or to Delete it, or use Create namespace to add one.
Management API
The management API is rooted at /api/custom/kv-store-management/stores. The store list returns
storeId, componentId, label, backendType, and processingTypes. Use the returned storeId in
/{storeId}/namespaces to list or create namespaces, and /{storeId}/namespaces/{namespace} to read one.
URL-encode both identifiers. Creating uses POST with {namespace, keyName, jsonSchema}; jsonSchema is
an object. Reads return {name, keyName, jsonSchema}. PUT /{storeId}/namespaces/{namespace}/description with
{description} changes the description only; an empty one removes it, and a namespace whose schema is not an
object cannot have one (400). All these endpoints require the Core.AdminAccess permission.
For Fluss, creation provisions a typed table in the store's database;
DELETE removes the table and all its data. Namespace names are unqualified table names.
Storage backends
The Key-Value Store keeps data in one of the following backends:
- Redis — entries are stored in a Redis instance. This is the default of an on-premise installation: the
Docker Compose installation bundle (the
nussknacker-installationimage) runs a Redis container next to the Designer and configures the store with it. Expired entries are removed natively by Redis. Further stores can be added via the Redis integration; each Redis integration adds a separate, dedicated Key-Value Store component to the palette. Size the Redis memory for the store's limits (maximum number of entries times maximum value size) and keep thenoevictionpolicy: when memory runs out, a write then fails with an error instead of Redis silently dropping entries that scenarios still rely on, such as deduplication keys. - Database — entries are stored in Nussknacker's own PostgreSQL database, the one the Designer keeps scenarios in
(
databaseKind: nussknacker-db). Nu Cloud uses it. It needs no additional service, but everygetandsetis a query against the Designer's database, and expired entries are only filtered out on read and cleaned up periodically, so on-premise installations use Redis. - Fluss — each namespace is a primary-key table in an Apache Fluss database
with the key column and typed value columns, see Fluss backend.
Entries never expire,
setreturns nokeyExisted, and the store can't be limited by maximum TTL or entry count. The physical schema defines the value type; null fields remain present. Deleting a namespace removes its table and data.
Apart from the Fluss differences above, the component behaves the same in scenarios — operations, typing and namespaces work identically.
Fluss backend
- Entries never expire, so the store has no TTL and no limit on the number of entries.
- There is no
defaultnamespace: its values are strings, and a Fluss namespace holds objects only. - Each namespace is an ordinary Fluss primary-key table that can be read with Flink SQL: the key column, named after the namespace key name, and the value columns.
Namespaces and tables
Each namespace is a table created by the Key-Value Store in its database. Selectors show only the
table name, such as users. Other tables are not listed.
Values contain every non-key column, including null fields. get returns null for an absent key, while table and
connection errors fail the operation. set replaces the entire row and finishes after Fluss acknowledges the write.
It returns an empty record and offers no TTL.
Delete namespace drops its table and all its data. A namespace used by an active scenario cannot be deleted. After deletion, a new empty namespace can be created with the same name. Running scenarios see the new namespace within 30 seconds.
Value schema
For a new namespace, supply an object with properties and additionalProperties: false. Each property becomes
a physical column. Nested closed objects, arrays and maps with typed additionalProperties are supported recursively.
A required property without a null alternative creates a non-null column; optional properties create nullable columns.
Read values retain every null field, including those in nested records. A missing input field writes null when its
column is nullable.
| JSON Schema | Fluss column type | Nussknacker type |
|---|---|---|
string | STRING | String |
boolean | BOOLEAN | Boolean |
integer | BIGINT | Long |
integer with format: int32 | INT | Integer |
number | DECIMAL(38,18) | BigDecimal |
number with format: float | FLOAT | Float |
number with format: double | DOUBLE | Double |
string with format: date | DATE | LocalDate |
string with format: time | TIME(0) | LocalTime |
string with format: local-date-time | TIMESTAMP(9) | LocalDateTime |
string with format: date-time | TIMESTAMP_LTZ(9) | Instant |
array with items | ARRAY | List |
Closed object with properties | ROW | Record |
object with typed additionalProperties and no properties | MAP with STRING keys | Map |
A time value is stored in whole seconds: fractions of a second are dropped.
Additional considerations
- The store can be configured with limits: maximum TTL, maximum key size, maximum value size and maximum number of entries. Exceeding a limit causes a runtime error for the processed record.
- The entry count limit may temporarily include entries that have already expired but have not been cleaned up yet.
setoperations are also performed when testing scenarios — test runs write to the same store.