Skip to main content

Redis Cache ExecModule

Overview

RedisCacheModule connects a ValkyrAI workflow to one TLS-enabled Redis database. Version 2.0 replaces the legacy process-local simulation with real bounded Redis commands, complete Workflow Studio metadata, IntegrationAccount-only credentials, normalized outputs, and credential-safe failures.

The module is registered as:

com.valkyrlabs.workflow.modules.cache.RedisCacheModule

It supports string keys, counters, TTL management, one-page cursor scans, and Pub/Sub publishing. It does not expose KEYS, Lua, arbitrary commands, list/hash/set command families, transactions, or pipelines.

Usage

  1. Create a Redis IntegrationAccount whose accountId is a rediss:// endpoint.
  2. Store the Redis password or token in an IntegrationAccount SecureField and mark the account READY.
  3. Bind that account through the module's redisAccount configuration.
  4. Select one supported operation and provide only its required inputs.
  5. Execute the workflow and inspect status, the operation-specific result, attempts, and error.

Every execution opens a bounded TLS connection, sends at most one Redis command, closes the connection, and reports attempts: 1 if a command was attempted.

Inputs

InputRequiredDescription
operationYesget, set, delete, exists, increment, decrement, expire, ttl, scan, or publish.
keyBy operationRedis key, at most 1,024 UTF-8 bytes. Required except for scan and publish.
valueFor setString or JSON-serializable value. Serialized size is capped at 1 MiB.
ttlSecondsBy operationOptional set TTL or required expire TTL. Range: 1–2,592,000 seconds. Use 0 to omit a set TTL.
onlyIfAbsentNoApplies Redis NX semantics to set. Default: false.
deltaNoPositive counter delta from 1 through 1,000,000,000. Default: 1.
patternFor scanRedis glob pattern, at most 512 UTF-8 bytes. Default: *.
cursorFor scanDecimal cursor returned by the previous nextCursor. Default: 0.
scanCountFor scanRedis SCAN count hint from 1 through 500. Default: 100.
channelFor publishPub/Sub channel, at most 512 UTF-8 bytes.
messageFor publishPub/Sub message, at most 1 MiB.

Raw password, apiKey, api_key, token, secret, auth, redisUrl, redis_url, mock, and test fields are rejected in workflow input and module configuration.

Outputs

OutputDescription
statussuccess or error.
operationNormalized Redis operation.
keyValidated key for a key-scoped operation.
valueString value for get, or integer value for counter operations.
existsWhether the key exists for get or exists.
resultNormalized Redis reply for set, delete, expire, or publish.
ttlSecondsRedis TTL: -2 for an absent key, -1 for a persistent key, or remaining seconds.
itemsKeys returned by one SCAN page.
countNumber of keys returned by the SCAN page.
nextCursorOpaque cursor for the next SCAN page.
hasMoreWhether Redis indicates that another SCAN page may exist.
attemptsRedis command attempts. Validation failures report 0; provider attempts report 1.
errorSafe object with code, message, and retryable.

Credentials, the full endpoint, raw provider exceptions, and command payloads are not returned.

IntegrationAccount Requirements

The bound IntegrationAccount must:

  • have status exactly READY;
  • put a TLS endpoint such as rediss://cache.example.com:6380/0 in accountId;
  • put the optional Redis ACL username in username;
  • put the Redis password or access token in the password SecureField, with apiKey accepted as a compatibility SecureField;
  • contain no credentials in accountId, query parameters, workflow input, or module configuration;
  • use a least-privilege Redis ACL limited to the documented keyspace and command allowlist.

Plaintext redis:// endpoints are rejected. The endpoint cannot contain user info, a query, or a fragment. Database indexes are limited to 0–255.

Configuration

ConfigurationDefaultConstraint
redisAccountNoneRequired READY IntegrationAccount.
operationNoneRequired allowlisted operation.
ttlSeconds00–2,592,000; positive only for set or expire.
onlyIfAbsentfalseRedis NX behavior for set.
delta11–1,000,000,000.
pattern*At most 512 UTF-8 bytes.
cursor0Decimal Redis cursor.
scanCount1001–500.
timeoutMs5000250–15,000 milliseconds.

The module does not accept a host, port, password, or provider URL as workflow configuration. Connection identity is owned by the IntegrationAccount.

Operations

get, exists, and ttl

Read one string key, test its existence, or read its remaining TTL. These operations send one command and do not retry automatically.

set

Writes one string value. Non-string input is serialized to bounded JSON. A positive ttlSeconds uses atomic Redis expiration semantics; onlyIfAbsent=true adds NX. NOT_STORED means the NX condition prevented the write.

delete and expire

Deletes one key or assigns a TTL. The integer/boolean provider result is normalized under result. These operations are writes even when Redis reports that no key changed.

increment and decrement

Uses atomic Redis integer commands with a positive bounded delta. Existing non-integer values fail as provider command errors.

scan

Reads one cursor page using SCAN, never blocking KEYS. Pass nextCursor back as cursor until hasMore is false. scanCount is a provider hint, not an exact page-size guarantee.

publish

Publishes one bounded message to one bounded channel and returns the subscriber count under result. Pub/Sub delivery is ephemeral and non-idempotent.

Errors and Failure Modes

CodeMeaningRecovery
VALIDATION_ERRORMissing or malformed input, unsafe endpoint, raw credential field, invalid size, or operation-specific constraint.Correct the named field. No Redis command was sent.
UNSUPPORTED_OPERATIONThe requested operation is outside the allowlist.Select a documented operation; migrate legacy pipeline/list/hash/set/Lua workflows explicitly.
INTEGRATION_ACCOUNT_ERRORNo account is bound, status is not READY, or the SecureField credential is absent.Repair and rebind the Redis IntegrationAccount.
REDIS_COMMAND_ERRORTLS connection, authentication, timeout, provider command, or response handling failed.Verify Redis availability and ACLs. Reconcile write state before retrying.

Provider exception text is deliberately not returned because Redis errors can echo keys, endpoints, usernames, or credential material. The module never silently switches to local memory.

Example

Store one JSON value for five minutes:

{
"operation": "set",
"key": "customer:42:summary",
"value": {
"tier": "pro",
"risk": "low"
},
"ttlSeconds": 300,
"onlyIfAbsent": false
}

Expected normalized result:

{
"status": "success",
"operation": "set",
"key": "customer:42:summary",
"result": "OK",
"attempts": 1
}

Notes

  • Pagination is explicit and bounded to one SCAN page per execution. Redis may return zero keys before the cursor reaches 0.
  • The module sends at most one provider command and does not automatically retry reads or writes. This prevents silent duplicate increments and Pub/Sub sends.
  • set with the same value is naturally repeatable, but the module is classified non-idempotent because increment, decrement, delete, expire, and publish have stateful side effects.
  • No operation supports dry-run. Use NX or a caller-owned key convention when conditional writes are required.
  • Redis Pub/Sub does not persist messages or guarantee that a subscriber consumed them. Reconcile business-critical delivery through a durable system instead.
  • The repository suite does not use a live Redis credential. It deterministically verifies request normalization, account enforcement, endpoint validation, size limits, secret redaction, error behavior, annotation scanning, and catalog serialization. Live TLS connectivity and provider ACL behavior remain a deployment-time boundary.