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
| Action | What it does |
|---|---|
| Add stream entry | Append an entry of named fields to a stream, a log that keeps every entry in order. |
| Add to list | Add items to the end (or start) of a list, creating the list if needed. |
| Add to set | Add members to a set, a collection without repeats. |
| 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. |
| Delete hash fields | Remove named fields from a hash. |
| Delete keys | Delete one or more keys, whatever they hold. |
| Find keys | List the keys whose names match a pattern, such as order:* for every key starting order:. |
| Get hash fields | Read every field of a hash, or only the ones named. |
| Get list items | Read a list's items by position without removing them. |
| Get set members | List a set's members, and check whether one value is among them. |
| Get value | Read the text stored under a key, and how long until it expires. |
| Increment number | Add to the number stored under a key and get the new number. |
| Publish message | Send a message to a channel. |
| 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. |
| Remove from set | Remove members from a set. |
| Run command | Send any other Redis command, such as ZADD for a leaderboard or GEOSEARCH, with its arguments. |
| Set expiry | Make a key expire after some seconds or at a moment. |
| Set hash fields | Set named fields of a hash, a record stored under one key, creating it if needed. |
| Set value | Store text, a number or JSON under a key, replacing what is there. |
| Take from list | Take 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
- Stream
streamtextRequired - The key of the stream, such as events:orders.
- Fields
fieldsobjectRequired - Each field's name with its value. Objects and lists are stored as JSON.
- Keep about
max_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
- List
keytextRequired - The key of the list, such as jobs:pending.
- Items
valueslistRequired - What to add, one per item. Objects are stored as JSON.
- Where
endtext - 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
- Set
keytextRequired - The key of the set, such as tags:featured.
- Members
memberslistRequired - 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
- Key
keytextRequired - 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
- Hash
keytextRequired - The key of the hash, such as customer:42.
- Fields
fieldslistRequired - 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
- Keys
keyslistRequired - 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
- Pattern
patterntext - * matches any text and ? one character. Leave empty for every key.
- Limit
limitnumber - 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
- Hash
keytextRequired - The key of the hash, such as customer:42.
- Fields
fieldslist - 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
- List
keytextRequired - The key of the list, such as jobs:pending.
- From position
startnumber - The first position to read. Defaults to 0, the first item.
- To position
stopnumber - 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
- Set
keytextRequired - The key of the set, such as tags:featured.
- Check for
membertext - 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
- Key
keytextRequired - 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
- Key
keytextRequired - The key's name, such as order:1042.
- By
bynumber - 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
- Channel
channeltextRequired - The channel's name, such as notifications.
- Message
messagetextRequired - 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
- Stream
streamtextRequired - The key of the stream, such as events:orders.
- After entry ID
after_idtext - Only entries added after this one, such as an earlier step's 'last_id'.
- Limit
limitnumber - The most entries to read, up to 1000. Defaults to 100.From 1 to 1000.
- Newest first
newest_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
- Set
keytextRequired - The key of the set, such as tags:featured.
- Members
memberslistRequired - 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
- Command
commandtextRequired - The command's name, such as ZADD.
- Arguments
argumentslist - 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
- Key
keytextRequired - 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 at
expire_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
- Hash
keytextRequired - The key of the hash, such as customer:42.
- Fields
fieldsobjectRequired - 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
- Key
keytextRequired - The key's name, such as order:1042.
- Value
valuetextRequired - 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 at
expire_atdate and time - Delete the key at this moment instead. Must be in the future.
- Store
conditiontext - 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
- List
keytextRequired - The key of the list, such as jobs:pending.
- Where
endtext - Which end to take from. Defaults to the start.One of:
end(End of the list),start(Start of the list). Default:start. - How many
countnumber - 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"
}