Redis Advanced icon

Redis Advanced

Get, send and update data in Redis with enhanced operations

Increment

AI-generated

Summary

Atomically increments the value of the given Redis key by 1, creating the key if it does not exist. Optionally sets an expiration time (TTL) on the key after incrementing.

Inputs

  • Key (required) — The name of the Redis key to increment.
  • Expire — Boolean flag to determine whether to set an expiration timeout on the key after incrementing.
  • TTL — If Expire is true, the number of seconds before the key expires.

Output shape

a single JSON object containing the incremented value under the key name provided as input

The output JSON object has one property with the key name and the incremented numeric value. If Expire is enabled and TTL specified, the key is set to expire after the TTL. Errors may be returned depending on connection or command failure.

Examples

Example 1: Increment a Redis key "counter" without expiration

Set Key to "counter", Expire to false (default). Expect incremented count value in output.

Example 2: Increment a Redis key "sessionCount" with an expiration of 300 seconds

Set Key to "sessionCount", Expire to true, TTL to 300. After incrementing, the key will expire in 300 seconds.

Discussion