getCache
Retrieve records from Redis.
This method communicates with the Redis server directly to get records associated with the given keys.
Signature
declare function getCache<Elements extends any[] = any[]>(
props: GetCacheProps
): Promise<[...Elements]>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | GetCacheProps | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
An array of records retrieved from Redis.
Referenced Types
Examples
Getting a single record.
import { sdk } from '~/sdk';
const [record] = await sdk.redis.getCache({ keys: ['example-key'] });Getting multiple records.
import { sdk } from '~/sdk';
const records = await sdk.redis.getCache({
keys: ['example-key-1', 'example-key-2']
});Typing the records.
import { sdk } from '~/sdk';
const records = await sdk.redis.getCache<[
{ key1: string },
{ key2: string },
]>({
keys: ['example-key-1', 'example-key-2']
});
console.log(records[0].key1);
console.log(records[1].key2);