As I know sDiff works only with sets. But how can i get diff between indexed lists?
....
$Redis->lPush("KEY1", "Value1");
$Redis->lPush("KEY1", "Value2");
$Redis->lPush("KEY1", "Value3");
$Redis->lPush("KEY2", "Value1");
$Redis->lPush("KEY2", "Value3");
$Redis->lPush("KEY2", "Value4");
$Redis->sDiff("KEY1", "KEY2");
....
There is no built-in command for that - your options are either pull the two lists and perform the comparison (for diff) in the client, or write a Lua script that is run with the
EVAL
command to perform it server-side. Here's an example for such a script:Running this with
redis-cli
looks like this:Redis doesn't have in-built support for finding list differences. But there is a workaround. By seeing the syntax of your code, I assume you are working on php. PHP array_diff() is to rescue. Following steps should work.
This approach can be translated to any other programming language.
p.s. If the lists are huge, make sure you get the difference in batch, instead of loading all the items at once.