SUNIONSTORE

SUNIONSTORE destination key [key …]

这个命令类似于 SUNION 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。

如果 destination 已经存在,则将其覆盖。

destination 可以是 key 本身。

可用版本:

>= 1.0.0

时间复杂度:

O(N), N 是所有给定集合的成员数量之和。

返回值:

结果集中的元素数量。

  1. redis> SMEMBERS NoSQL
  2. 1) "MongoDB"
  3. 2) "Redis"
  4. redis> SMEMBERS SQL
  5. 1) "sqlite"
  6. 2) "MySQL"
  7. redis> SUNIONSTORE db NoSQL SQL
  8. (integer) 4
  9. redis> SMEMBERS db
  10. 1) "MySQL"
  11. 2) "sqlite"
  12. 3) "MongoDB"
  13. 4) "Redis"

原文: https://wizardforcel.gitbooks.io/redis-doc/content/ref/98.html