For AI agents: the complete documentation index is available at /hclapi/llms.txt, the full documentation bundle is available at /hclapi/llms-full.txt, and this page is available as Markdown at /hclapi/docs/steps/valkey.md.

valkey

The valkey step executes cache commands or Pub/Sub subscriptions against a declared connection "valkey" instance.

# Read from cache
valkey "check_cache" {
  connection = "cache"
  op         = "get"
  key        = "users:${ctx.request.path.id}"
}

# Write with TTL
valkey "save_cache" {
  connection = "cache"
  op         = "set"
  key        = "users:${ctx.request.path.id}"
  value      = steps.fetch_user.row
  ttl        = "15m"
}

# Delete key
valkey "purge" {
  connection = "cache"
  op         = "del"
  key        = "users:${ctx.request.path.id}"
}

# Real-time Pub/Sub subscription
valkey "live_alerts" {
  connection = "cache"
  op         = "subscribe"
  channel    = "system.alerts"
}

Attributes

AttributeTypeRequiredDescription
connectionstringyesDeclared connection "valkey" identifier
opstringyes"get", "set", "del", or "subscribe"
keystringfor get/set/delCache key expression
valueanyfor setPayload serialized as a JSON string
channelstringfor subPub/Sub channel name expression
ttlDurationnoExpiration duration like "10m" or "24h"
whenboolnoConditional expression

Exported outputs

For op = "get"

  • steps.<name>.found: true if the key exists, false on a cache miss.
  • steps.<name>.value: Unmarshaled JSON data, or null if missing.

A cache miss sets found = false without an error, allowing conditional fallbacks:

sql "fetch_db" {
  when       = !steps.check_cache.found
  connection = "main"
  query      = "SELECT id, email FROM users WHERE id = @id"
  args       = { id = ctx.request.path.id }
}

For op = "set" and op = "del"

  • steps.<name>.success: true when the operation succeeds.

For op = "subscribe"

  • steps.<name>.stream: An iter.Seq2[any, error] iterator yielding real-time messages. Pipe this directly into a terminal stream "sse" step.