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
Property | Description | Type |
---|---|---|
<action-id> | Unique identifier for the action | string |
type | Type of the action | string |
props | Properties specific to this action. Refer to props section for more details. | object |
props
Property | Description | Type | Required |
---|---|---|---|
queryType | The type of Redis query. See the queryType section for more details | string | true |
entries | Key-value pairs for Redis MSET operation | object | (Conditional) |
keys | List of keys for Redis MGET or DEL operations | array | (Conditional) |
queryType
Property | Description |
---|---|
MSET | Sets multiple keys to multiple values |
MGET | Gets the values of all the specified keys |
DEL | Deletes one or more keys |
Output
📝 Note: Can be accessed using
context["last_output"]
Key | Description | Type |
---|---|---|
result | Outcome 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 |
timeTaken | Time taken for the operation, in milliseconds. | long |
error | Error message, if any, produced while executing the operation. | string |
result
Property | Description | Type |
---|---|---|
MSET | Returns a success message indicating the status of the operation. | string |
MGET | Returns a list of values corresponding to the requested keys. | array |
DEL | Returns 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