SINTER

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Get the intersection

Usage is sinter key1 key2.
myset1 = { A, B, C }
myset2 = { B, C, D }
SINTER myset1 myset2 = { B, C }

Example

Command>sadd myset1 A B C
Result>3
Command>sadd myset2 B C D
Result>3
Command>sinter myset1 myset2
Result> 1) B
2) C

View animation


Intersection of three sets

Usage is sinter key1 key2 key3.
myset1 = { A, B, C }
myset2 = { B, C, D }
myset3 = { C, E, F }
SINTER myset1 myset2 myset3 = { C }

There is no limit on the number of keys.

Example

Command>sadd myset3 C E F
Result>3
Command>sinter myset1 myset2 myset3
Result> 1) C

Sort feature

sort or asc sorts in ascending order; desc sorts in descending order.

Example

Command>sinter myset1 myset2 sort
Result> 1) B
2) C
Command>sinter myset1 myset2 desc
Result> 1) C
2) B
Note The sort feature is available on an Enterprise server.


Syntax

SINTER key [key ...] [sort|asc|desc]

  • Available since version 1.0.0.
  • Time complexity is O(N*M). N is the number of members in the smallest set,
    and M is the number of sets.
SQL Select If you are using Redis Enterprise 7.3.0 or later, try SELECT.
Related commands SUNION, SDIFF, SINTERSTORE
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< SUNION SINTER SDIFF >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.