RedisInsight-plugin-sdk
The high-level API for communication between RedisInsight
plugin and RedisInsight application.
Usage
npm install redisinsight-plugin-sdk
or
yarn add redisinsight-plugin-sdk
Available methods
Sets any custom text to the header of the command result
Parameters:
Example:
import { setHeaderText } from 'redisinsight-plugin-sdk';
setHeaderText('Matched: 10')
executeRedisCommand(command)
Executes a Redis command (currently, only read-only commands are supported).
Parameters:
command
{String} - command to execute
Returns:
Promise<[{ response, status }]>
Example:
import { executeRedisCommand } from 'redisinsight-plugin-sdk';
try {
const result = await executeRedisCommand('GET foo');
const [{ response, status }] = result;
if (status === 'success') {
}
} catch (e) {
console.error(e);
}
getState()
Returns saved state for the command visualization.
Throw an error if the state has not been saved.
Parameters:
state
{any} - any data to save
Returns:
Example:
import { getState } from 'redisinsight-plugin-sdk';
try {
const result = await getState();
} catch (e) {
console.error(e);
}
setState(state)
Save the state for the command visualization.
Returns:
Example:
import { setState } from 'redisinsight-plugin-sdk';
try {
await setState({ a: 1, b: 2 });
} catch (e) {
console.error(e);
}
formatRedisReply(response, command)
Util function to parse Redis response
Returns string with parsed cli-like response
Returns:
Example:
import { formatRedisReply } from 'redisinsight-plugin-sdk';
try {
const parsedReply = await formatRedisReply(data[0].response, command);
} catch (e) {
console.error(e);
}