Redis Sinterstore 命令將給定集合之間的交集存儲在指定的集合中。如果指定的集合已經(jīng)存在,則將其覆蓋。
redis Sinterstore 命令基本語法如下:
redis 127.0.0.1:6379> SINTERSTORE DESTINATION_KEY KEY KEY1..KEYN
>= 1.0.0
返回存儲交集的集合的元素數(shù)量。
redis 127.0.0.1:6379> SADD myset1 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "foo" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "bar" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset2 "world" (integer) 1 redis 127.0.0.1:6379> SINTERSTORE myset myset1 myset2 (integer) 1 redis 127.0.0.1:6379> SMEMBERS myset 1) "hello"