Within my custom node, I need to access Redis to retrieve data generated during a previous workflow execution.
Here’s a simplified outline of the execute method where this access is needed:
const input = this.getInputData(0)[0]
var sessionId = input.json.sessionId
if (sessionId) {
const session = redis.get(sessionId) // Pseudocode to Get Data from redis using the sessionId as key
if (session) {
responseData = {
isNewSession : false,
... other fields ...
}
// globalSessions[sessionId.toString()] = true
else {
responseData = {
isNewSession : true,
... other fields ...
}
sessionData = { ... }
redis.set(sessionId, sessionData) // Pseudocode to set data on redis
}
const returnItem: INodeExecutionData = {
json: {
responseData: responseData,
},
};
How can I achieve this? Specifically, my question is: How can I obtain a reference to the Redis instance from within my custom node’s code?
Furthermore, is it possible to use a more convenient or abstracted solution for this, perhaps similar to how the ‘IA Simple Memory’ node handles persistent data?
Ideally, I would like to offer both methods (direct Redis access and a potentially simpler alternative) so the user can choose the most suitable option. Any help or examples would be greatly appreciated