redis@1.2.4
- get(key)
- hget(key, field)
- hGetAll(key)
- hset(key, value)
- jGet(key)
- jSet(key, value)
- mGet(keys)
- scan(pattern, options)
- set(key, value)
This adaptor exports the following from common:
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- lastReferenceValue()
- merge()
- sourceValue()
Functions
get
get(key) ⇒ Operation
Get the string value of a key.
If the key does not exist, null is returned.
An error is thrown if the value stored at key is not a string, because get()
only handles string values.
Param | Type | Description |
---|---|---|
key | string | The name of the key |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the result returned from Redis |
references | an array of all previous data objects used in the Job |
Example: Get the value of the patient key
get("patient");
hget
hget(key, field) ⇒ Operation
Get the value associated with a specific field in a hash stored at a specified key.
Param | Type | Description |
---|---|---|
key | string | The name of the key |
field | string | Field |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the result returned from Redis |
references | an array of all previous data objects used in the Job |
Example: Get the value of the name field under the patient key
hget("patient", "name");
hGetAll
hGetAll(key) ⇒ Operation
Get all fields and values of a hash, as an object, for a specified key.
Param | Type | Description |
---|---|---|
key | string | The name of the key |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | The hash as an object |
references | an array of all previous data objects used in the Job |
Example: Get the hash obejct at the noderedis:animals:1 key
hGetAll("noderedis:animals:1");
hset
hset(key, value) ⇒ Operation
Sets the specified fields to their respective values in the hash stored at key. This function overwrites the values of specified fields that exist in the hash. If key doesn't exist, a new key holding a hash is created.
Param | Type | Description |
---|---|---|
key | string | The name of the key |
value | object | The values to set |
This operation writes the following keys to state:
State Key | Description |
---|---|
references | an array of all previous data objects used in the Job |
Example: Set a field and value for the patient
key
hset('patient', { name: 'mtuchi' });
Example: Set multiple field values for the patient
key
hset('patient', { name: 'victor', ihs_number: 12345 });
jGet
jGet(key) ⇒ Operation
Get the value at a specified path in a JSON document stored in a key
Param | Type | Description |
---|---|---|
key | string | The key at which the JSON document is stored. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the result returned from Redis |
references | an array of all previous data objects used in the Job |
Example: Get JSON document value of the patient key
jGet("patient");
jSet
jSet(key, value) ⇒ Operation
Creates a JSON object at the specified key. If the key already exists, the existing value will be replaced by the new value.
Param | Type | Description |
---|---|---|
key | string | The key to modify. |
value | string | object | The JSON object or string value to set. |
This operation writes the following keys to state:
State Key | Description |
---|---|
references | an array of all previous data objects used in the Job |
Example: Set a JSON object for the key patient
jSet('patient', { name: 'victor', ihs_number: 12345 });
mGet
mGet(keys) ⇒ Operation
Get the values at specified paths in JSON documents stored at multiple keys.
Param | Type | Description |
---|---|---|
keys | Array.<string> | The keys at which the JSON documents are stored. |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | the result returned from Redis |
references | an array of all previous data objects used in the Job |
Example: Get JSON document values of the patient and doctor keys
mGet(["patient", "doctor"]);
scan
scan(pattern, options) ⇒ Operation
Returns all keys which match the provided pattern. scan iterates the whole database to find the matching keys
Param | Type | Description |
---|---|---|
pattern | string | A glob-style pattern |
options | ScanOptions | Scan options |
This operation writes the following keys to state:
State Key | Description |
---|---|
data | an array of keys which match the pattern |
references | an array of all previous data objects used in the Job |
Example: Scan for matching keys
scan('*:20240524T172736Z*');
Example: Scan for keys and fetch the string values inside
scan('*:20240524T172736Z*');
each($.data, get($.data).then((state) => {
state.results ??= [];
state.results.push(state.data)
return state;
})
set
set(key, value) ⇒ Operation
Set the string value of a key. If the key already exists, its value is updated. Otherwise, a new key-value pair is created.
Param | Type | Description |
---|---|---|
key | string | The name of the key |
value | string | The value to set |
This operation writes the following keys to state:
State Key | Description |
---|---|
references | an array of all previous data objects used in the Job |
Example: Set the "patient" key to value "mtuchi"
set("patient", "mtuchi");
Interfaces
ScanOptions
Options provided to the scan function
Properties
Name | Type | Description |
---|---|---|
type | string | Limits the keys returned to those of a specified type (e.g., string, list, set, hash, json, zset or stream). |
count | integer | A hint to the server about how many elements to return in the call (default is 10). |