Skip to main content

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.

ParamTypeDescription
keystringThe name of the key

This operation writes the following keys to state:

State KeyDescription
datathe result returned from Redis
referencesan 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.

ParamTypeDescription
keystringThe name of the key
fieldstringField

This operation writes the following keys to state:

State KeyDescription
datathe result returned from Redis
referencesan 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.

ParamTypeDescription
keystringThe name of the key

This operation writes the following keys to state:

State KeyDescription
dataThe hash as an object
referencesan 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.

ParamTypeDescription
keystringThe name of the key
valueobjectThe values to set

This operation writes the following keys to state:

State KeyDescription
referencesan 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

ParamTypeDescription
keystringThe key at which the JSON document is stored.

This operation writes the following keys to state:

State KeyDescription
datathe result returned from Redis
referencesan 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.

ParamTypeDescription
keystringThe key to modify.
valuestring | objectThe JSON object or string value to set.

This operation writes the following keys to state:

State KeyDescription
referencesan 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.

ParamTypeDescription
keysArray.<string>The keys at which the JSON documents are stored.

This operation writes the following keys to state:

State KeyDescription
datathe result returned from Redis
referencesan 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

ParamTypeDescription
patternstringA glob-style pattern
optionsScanOptionsScan options

This operation writes the following keys to state:

State KeyDescription
dataan array of keys which match the pattern
referencesan 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.

ParamTypeDescription
keystringThe name of the key
valuestringThe value to set

This operation writes the following keys to state:

State KeyDescription
referencesan 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

NameTypeDescription
typestringLimits the keys returned to those of a specified type (e.g., string, list, set, hash, json, zset or stream).
countintegerA hint to the server about how many elements to return in the call (default is 10).