StateMachine icon

StateMachine

Get, send and update data in Redis

Check&Store

AI-generated

Summary

Check if a key representing a value exists in Redis, and if not, store the value under a hashed key. Optionally set an expiration TTL on the stored key.

Inputs

  • Value (required) — The name or string representing the key to check and potentially store in Redis.
  • Global Statement — Determines whether the key is stored in a global scope or limited to the current workflow level (default is global).
  • Expire — Indicates whether to set a timeout (expiration) on the stored key.
  • TTL — The time-to-live in seconds before the key expires; only applicable if Expire is true.

Output shape

A list of items each containing a JSON object with a 'state' property.

  • If the key did not exist and the value was stored, 'state' contains the stored value. - If the key already exists, 'state' is set to false. - Errors during Redis operations will throw and stop execution.

Examples

Example 1: Store a new unique value with a 1-hour expiration if it does not already exist globally.

Set 'Value' to the target string, enable 'Expire', set 'TTL' to 3600, and keep 'Global Statement' enabled.

Links

Discussion