Redis

App · 20 actions

Read and write a Redis database: store and read values with expiries, count, queue with lists, keep records in hashes and sets, publish messages and add to streams. Start a workflow for each new stream entry.

Actions

ActionWhat it does
Add stream entryAppend an entry of named fields to a stream, a log that keeps every entry in order.
Add to listAdd items to the end (or start) of a list, creating the list if needed.
Add to setAdd members to a set, a collection without repeats.
Check keyFind out whether a key exists, what kind of value it holds (string, list, hash, set, sorted set or stream) and when it expires.
Delete hash fieldsRemove named fields from a hash.
Delete keysDelete one or more keys, whatever they hold.
Find keysList the keys whose names match a pattern, such as order:* for every key starting order:.
Get hash fieldsRead every field of a hash, or only the ones named.
Get list itemsRead a list's items by position without removing them.
Get set membersList a set's members, and check whether one value is among them.
Get valueRead the text stored under a key, and how long until it expires.
Increment numberAdd to the number stored under a key and get the new number.
Publish messageSend a message to a channel.
Read stream entriesRead a stream's entries without removing them: from the oldest, or the newest first, and only those after an entry ID if given.
Remove from setRemove members from a set.
Run commandSend any other Redis command, such as ZADD for a leaderboard or GEOSEARCH, with its arguments.
Set expiryMake a key expire after some seconds or at a moment.
Set hash fieldsSet named fields of a hash, a record stored under one key, creating it if needed.
Set valueStore text, a number or JSON under a key, replacing what is there.
Take from listTake items off the start (or end) of a list, removing them.

Add stream entry

Append an entry of named fields to a stream, a log that keeps every entry in order. Creates the stream if needed.

Inputs

StreamstreamtextRequired
The key of the stream, such as events:orders.
FieldsfieldsobjectRequired
Each field's name with its value. Objects and lists are stored as JSON.
Keep aboutmax_lengthnumber
Trim the stream to roughly this many of its newest entries. Leave empty to keep every entry.At least 1.

Outputs

idtext
The new entry's ID, such as 1712345678901-0
lengthnumber
How many entries the stream has now
streamtext
The stream
Example output
{
  "id": "1712345678901-0",
  "length": 12,
  "stream": "events:orders"
}

Add to list

Add items to the end (or start) of a list, creating the list if needed. Handy as a simple queue.

Inputs

ListkeytextRequired
The key of the list, such as jobs:pending.
ItemsvalueslistRequired
What to add, one per item. Objects are stored as JSON.
Whereendtext
Which end of the list to use.One of: end (End of the list), start (Start of the list).

Outputs

added_countnumber
How many items were added
keytext
The key
lengthnumber
How many items the list has now
Example output
{
  "added_count": 1,
  "key": "jobs:pending",
  "length": 3
}

Add to set

Add members to a set, a collection without repeats. A member already in it is not added twice.

Inputs

SetkeytextRequired
The key of the set, such as tags:featured.
MembersmemberslistRequired
The values, one per item.

Outputs

added_countnumber
Members that were new
keytext
The key
sizenumber
How many members the set has now
Example output
{
  "added_count": 1,
  "key": "tags:featured",
  "size": 4
}

Check key

Find out whether a key exists, what kind of value it holds (string, list, hash, set, sorted set or stream) and when it expires.

Inputs

KeykeytextRequired
The key's name, such as order:1042.

Outputs

existstrue/false
True when the key exists
expires_in_secondsnumber
Seconds until the key expires; empty when it never does
keytext
The key
typetext
string, list, hash, set, zset or stream
Example output
{
  "exists": true,
  "expires_in_seconds": null,
  "key": "order:1042",
  "type": "string"
}

Delete hash fields

Remove named fields from a hash. The hash is deleted once it has none.

Inputs

HashkeytextRequired
The key of the hash, such as customer:42.
FieldsfieldslistRequired
The fields to remove, one per item.

Outputs

deleted_countnumber
How many fields were removed
keytext
The key
Example output
{
  "deleted_count": 1,
  "key": "customer:42"
}

Delete keys

Delete one or more keys, whatever they hold. Missing keys are skipped.

Inputs

KeyskeyslistRequired
The keys to delete, one per item.

Outputs

deleted_countnumber
How many of them existed and were deleted
keyslist
The keys asked for
Example output
{
  "deleted_count": 1,
  "keys": [
    "order:1042"
  ]
}

Find keys

List the keys whose names match a pattern, such as order:* for every key starting order:. Safe on a busy server: Redis is read in small steps.

Inputs

Patternpatterntext
* matches any text and ? one character. Leave empty for every key.
Limitlimitnumber
The most keys to return, up to 1000. Defaults to 100.From 1 to 1000.

Outputs

countnumber
How many were returned
has_moretrue/false
True when more keys match than were returned
keyslist
The matching keys, in name order
patterntext
The pattern matched
Example output
{
  "count": 2,
  "has_more": false,
  "keys": [
    "order:1041",
    "order:1042"
  ],
  "pattern": "order:*"
}

Get hash fields

Read every field of a hash, or only the ones named.

Inputs

HashkeytextRequired
The key of the hash, such as customer:42.
Fieldsfieldslist
Only these fields, one per item. Leave empty for all of them.

Outputs

countnumber
How many fields were read
fieldsobject
Each field's name and value
foundtrue/false
True when any of the fields exist
keytext
The key
Example output
{
  "count": 2,
  "fields": {
    "name": "Ada",
    "plan": "pro"
  },
  "found": true,
  "key": "customer:42"
}

Get list items

Read a list's items by position without removing them. Positions start at 0; -1 is the last item.

Inputs

ListkeytextRequired
The key of the list, such as jobs:pending.
From positionstartnumber
The first position to read. Defaults to 0, the first item.
To positionstopnumber
The last position to read. Defaults to -1, the last item.

Outputs

countnumber
How many items were read
itemslist
The items, in list order
keytext
The key
lengthnumber
How many items the whole list has
Example output
{
  "count": 2,
  "items": [
    "job-17",
    "job-18"
  ],
  "key": "jobs:pending",
  "length": 2
}

Get set members

List a set's members, and check whether one value is among them.

Inputs

SetkeytextRequired
The key of the set, such as tags:featured.
Check formembertext
A value to look for. Leave empty to only list.

Outputs

countnumber
How many members the set has
is_membertrue/false
Whether 'Check for' is a member; empty when not asked
keytext
The key
memberslist
The members, in name order
Example output
{
  "count": 2,
  "is_member": true,
  "key": "tags:featured",
  "members": [
    "blue",
    "green"
  ]
}

Get value

Read the text stored under a key, and how long until it expires. A missing key comes back with 'found' false rather than failing.

Inputs

KeykeytextRequired
The key's name, such as order:1042.

Outputs

expires_in_secondsnumber
Seconds until the key expires; empty when it never does
foundtrue/false
True when the key holds a value
keytext
The key
valuetext
The text stored; empty when the key is missing
Example output
{
  "expires_in_seconds": 3540,
  "found": true,
  "key": "order:1042",
  "value": "{\"status\": \"paid\"}"
}

Increment number

Add to the number stored under a key and get the new number. A missing key starts at 0. Use a negative amount to count down.

Inputs

KeykeytextRequired
The key's name, such as order:1042.
Bybynumber
How much to add, such as 1, -1 or 2.5. Defaults to 1.

Outputs

keytext
The key
valuenumber
The number after adding
Example output
{
  "key": "visits:today",
  "value": 42
}

Publish message

Send a message to a channel. Only programs subscribed at that moment receive it; nothing is kept. To keep messages, add them to a stream.

Inputs

ChannelchanneltextRequired
The channel's name, such as notifications.
MessagemessagetextRequired
The message. An object is sent as JSON.

Outputs

channeltext
The channel
receiversnumber
How many subscribers received it
Example output
{
  "channel": "notifications",
  "receivers": 2
}

Read stream entries

Read a stream's entries without removing them: from the oldest, or the newest first, and only those after an entry ID if given.

Inputs

StreamstreamtextRequired
The key of the stream, such as events:orders.
After entry IDafter_idtext
Only entries added after this one, such as an earlier step's 'last_id'.
Limitlimitnumber
The most entries to read, up to 1000. Defaults to 100.From 1 to 1000.
Newest firstnewest_firsttrue/false
Read from the newest entry back. Off reads from the oldest.Default: false.

Outputs

countnumber
How many entries were read
entrieslist
The entries read
last_idtext
The ID of the last entry read; empty when none
streamtext
The stream
Example output
{
  "count": 1,
  "entries": [
    {
      "added_at": "2024-04-05T19:34:38.901Z",
      "fields": {
        "order": "1042",
        "status": "paid"
      },
      "id": "1712345678901-0"
    }
  ],
  "last_id": "1712345678901-0",
  "stream": "events:orders"
}

Remove from set

Remove members from a set. The set is deleted once it is empty.

Inputs

SetkeytextRequired
The key of the set, such as tags:featured.
MembersmemberslistRequired
The values, one per item.

Outputs

keytext
The key
removed_countnumber
How many members were removed
Example output
{
  "key": "tags:featured",
  "removed_count": 1
}

Run command

Send any other Redis command, such as ZADD for a leaderboard or GEOSEARCH, with its arguments. Commands that wipe or stop the server are refused.

Inputs

CommandcommandtextRequired
The command's name, such as ZADD.
Argumentsargumentslist
Its arguments in order, one per item, such as leaderboard, 10, ada.

Outputs

commandtext
The command as sent
resulttext
Redis's answer: text, a number, or a list of them
Example output
{
  "command": "ZADD leaderboard 10 ada",
  "result": 1
}

Set expiry

Make a key expire after some seconds or at a moment. With neither, the key's expiry is removed so it is kept.

Inputs

KeykeytextRequired
The key's name, such as order:1042.
Expire in (seconds)expire_in_secondsnumber
Delete the key this many seconds from now, such as 3600 for an hour. Leave empty, with no 'Expire at', to keep it.At least 1.
Expire atexpire_atdate and time
Delete the key at this moment instead. Must be in the future.

Outputs

expires_in_secondsnumber
Seconds until the key expires; empty when it never does
foundtrue/false
False when the key does not exist
keytext
The key
Example output
{
  "expires_in_seconds": 3600,
  "found": true,
  "key": "order:1042"
}

Set hash fields

Set named fields of a hash, a record stored under one key, creating it if needed. Other fields are left as they are.

Inputs

HashkeytextRequired
The key of the hash, such as customer:42.
FieldsfieldsobjectRequired
Each field's name with its value. Objects and lists are stored as JSON.

Outputs

added_countnumber
Fields that were new
keytext
The key
updated_countnumber
Fields that already existed and were replaced
Example output
{
  "added_count": 2,
  "key": "customer:42",
  "updated_count": 0
}

Set value

Store text, a number or JSON under a key, replacing what is there. It can expire after some seconds or at a moment, and can be stored only if the key is new (for a lock) or only if it already exists.

Inputs

KeykeytextRequired
The key's name, such as order:1042.
ValuevaluetextRequired
What to store. An object or list is stored as JSON.
Expire in (seconds)expire_in_secondsnumber
Delete the key this many seconds from now, such as 3600 for an hour. Leave empty, with no 'Expire at', to keep it.At least 1.
Expire atexpire_atdate and time
Delete the key at this moment instead. Must be in the future.
Storeconditiontext
When to store it. Defaults to always.One of: always, if_missing (Only if the key doesn't exist yet), if_exists (Only if the key already exists). Default: always.

Outputs

keytext
The key
storedtrue/false
False when the condition kept the value from being stored
valuetext
The text stored
Example output
{
  "key": "order:1042",
  "stored": true,
  "value": "{\"status\": \"paid\"}"
}

Take from list

Take items off the start (or end) of a list, removing them. With items added at the end, this takes the oldest first.

Inputs

ListkeytextRequired
The key of the list, such as jobs:pending.
Whereendtext
Which end to take from. Defaults to the start.One of: end (End of the list), start (Start of the list). Default: start.
How manycountnumber
How many items to take. Defaults to 1.From 1 to 1000.

Outputs

countnumber
How many were taken; 0 when the list was empty
itemslist
The items taken, in the order taken
keytext
The key
Example output
{
  "count": 1,
  "items": [
    "job-17"
  ],
  "key": "jobs:pending"
}

On this page