Skip to main content

DB::REDIS

Perform Redis queries.

Prerequisite

Syntax

actions:
<action-id>:
type: DB::REDIS
props:
queryType: <query_type>
entries: # for MSET
<key1>: <value1>
<key2>: <value2>
...
keys: # for MGET and DEL
- <key1>
- <key2>
...

Properties

PropertyDescriptionType
<action-id>Unique identifier for the actionstring
typeType of the actionstring
propsProperties specific to this action. Refer to props section for more details.object

props

PropertyDescriptionTypeRequired
queryTypeThe type of Redis query. See the queryType section for more detailsstringtrue
entriesKey-value pairs for Redis MSET operationobject(Conditional)
keysList of keys for Redis MGET or DEL operationsarray(Conditional)

queryType

PropertyDescription
MSETSets multiple keys to multiple values
MGETGets the values of all the specified keys
DELDeletes one or more keys

Output

📝 Note: Can be accessed using context["last_output"]

KeyDescriptionType
resultOutcome of the query, which could be a success message, a list of values, or a count of affected keys. Refer to result section.object or array
timeTakenTime taken for the operation, in milliseconds.long
errorError message, if any, produced while executing the operation.string

result

PropertyDescriptionType
MSETReturns a success message indicating the status of the operation.string
MGETReturns a list of values corresponding to the requested keys.array
DELReturns the count of keys that were successfully deleted.long
{ "result": "OK" }
{
"result": ["value10", "value11"]
}
{ "result": 2 }

Example

redisTests.yml
actions:
setKeyValue:
type: DB::REDIS
props:
queryType: MSET
entries:
user: '{"name":"John"}'

getValue:
type: DB::REDIS
props:
queryType: MGET
keys:
- user

deleteKey:
type: DB::REDIS
props:
queryType: DEL
keys:
- user

tests:
redisTest:
tasks:
- resource: resources.redis
action: actions.setKeyValue
- resource: resources.redis
action: actions.getValue
- resource: resources.redis
action: actions.deleteKey