Closed ambrosekwok closed 4 years ago
Hi @ambrosekwok since the first version of redis IN and OUT I've used this nodes to send and receive json objects, and ever Redis OUT serialize data and Redis IN convert serialized data to js object again. I understand that is not the default behavior of Redis and I've been changed Redis IN and OUT, adding a checkbox if you need to serialize and unserialize json data. See it on version 1.3.7.
Hello,
I find that there are extra double quotes when PUSH a string into Redis. Currently, I use below code inside node-red function node to PUSH into Redis, and this will not add the extra double quotes. How could I avoid adding the extra double quotes using the redis out node?
let redis = context.flow.get('redis'); redis.call("RPUSH","test",msg.payload)
node-red-contrib-redis version: 1.3.5
Below is the node-red flows I tested.
[{"id":"8be122e0.82a4e","type":"inject","z":"723d049d.e2b66c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":360,"wires":[["95b91eec.41d48"]]},{"id":"6dfb263c.58ff58","type":"debug","z":"723d049d.e2b66c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":650,"y":400,"wires":[]},{"id":"f1c0de2f.c392e","type":"function","z":"723d049d.e2b66c","name":"RPUSH","func":"let redis = context.flow.get('redis');\nredis.call(\"RPUSH\",\"test\",msg.payload)\n\n","outputs":0,"noerr":0,"initialize":"","finalize":"","x":640,"y":260,"wires":[]},{"id":"8c0c3420.e2f7e8","type":"redis-out","z":"723d049d.e2b66c","server":"fbf941b1.4992b","command":"rpush","name":"RPUSH","topic":"test","x":640,"y":360,"wires":[]},{"id":"333fe7cc.0450e8","type":"redis-command","z":"723d049d.e2b66c","server":"fbf941b1.4992b","command":"lrange","name":"","topic":"test","params":"[]","paramsType":"json","x":460,"y":500,"wires":[["37f7efba.5d46b"]]},{"id":"f27f9318.fbc85","type":"inject","z":"723d049d.e2b66c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0,1]","payloadType":"json","x":270,"y":500,"wires":[["333fe7cc.0450e8"]]},{"id":"37f7efba.5d46b","type":"debug","z":"723d049d.e2b66c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":650,"y":500,"wires":[]},{"id":"89eb63be.47257","type":"redis-instance","z":"723d049d.e2b66c","server":"fbf941b1.4992b","name":"","topic":"redis","location":"flow","block":false,"x":270,"y":100,"wires":[]},{"id":"95b91eec.41d48","type":"function","z":"723d049d.e2b66c","name":"ToString","func":"msg.payload = msg.payload.toString()\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":360,"wires":[["8c0c3420.e2f7e8","6dfb263c.58ff58"]]},{"id":"82c48fd4.320e1","type":"inject","z":"723d049d.e2b66c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"str","x":270,"y":160,"wires":[["10ce9ce0.7ccbf3"]]},{"id":"10ce9ce0.7ccbf3","type":"function","z":"723d049d.e2b66c","name":"FLUSHALL","func":"let redis = context.flow.get('redis');\n\n\nredis.call(\"FLUSHALL\").then((data)=>{\n msg.payload = data\n node.send(msg);\n})","outputs":1,"noerr":0,"x":430,"y":160,"wires":[["f1d22ec7.bf176"]]},{"id":"f1d22ec7.bf176","type":"debug","z":"723d049d.e2b66c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":650,"y":160,"wires":[]},{"id":"53f5aa88.e00c74","type":"inject","z":"723d049d.e2b66c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":260,"wires":[["688476ab.1723a8"]]},{"id":"688476ab.1723a8","type":"function","z":"723d049d.e2b66c","name":"ToString","func":"msg.payload = msg.payload.toString()\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":260,"wires":[["f1c0de2f.c392e","8dc2f17f.33362"]]},{"id":"8dc2f17f.33362","type":"debug","z":"723d049d.e2b66c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":650,"y":300,"wires":[]},{"id":"fbf941b1.4992b","type":"redis-config","z":"","name":"local","options":"{}","cluster":false,"optionsType":"json"}]
Thank you.
Ambrose