T
T
tigra2018-11-13 15:30:07
Redis
tigra, 2018-11-13 15:30:07

How to select unique values ​​from an array in redis?

I need to merge several arrays and get unique values, you can merge using SUNION, but how to isolate unique values?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2018-11-13
@tigroid3

If you have a SUNION, then you have sets, and in sets the values ​​are already unique.

$ redis-cli
127.0.0.1:6379> sadd set1 a b c
(integer) 3
127.0.0.1:6379> sadd set2 b c d
(integer) 3
127.0.0.1:6379> sunion set1 set2
1) "b"
2) "c"
3) "d"
4) "a"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question