node-redis
node-redis copied to clipboard
SDIFF not returning correct response
If I add values to 2 different sets via SADD and then try to diff them using the SDIFF method, the wrong result is returned. But, if I run sendCommand(['SDIFF', 'key1', 'key2']) it returns the correct result.
For Example:
import redis from 'redis';
const client = redis.createClient();
await client.connect();
const array1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
const array2 = ['d', 'c', 'f', 'a'];
await client.SADD('key1', array1);
await client.SADD('key2', array2);
const badDiff = await client.SDIFF('key1', 'key2');
console.log('Bad Diff: ', badDiff);
// Bad Diff: [ 'g', 'a', 'd', 'c', 'f', 'b', 'e' ] (Incorrect!)
const goodDiff = await client.sendCommand(['SDIFF', 'key1', 'key2']);
console.log('Good Diff: ', goodDiff);
// Good Diff: [ 'g', 'b', 'e' ] (Correct!)
It doesn't make a lot of sense why this would be happening but its easily verifiable.
Environment:
- Node.js Version: 18.7.0
- Redis Server Version: 7.0.4
- Node Redis Version: 4.3.1
- Platform: MacOS 12.5.1 & AlmaLinux 8.6