Latest web development tutorials

RedisのSunionstoreコマンド

Redisのセット(セット)

RedisのSunionstoreは、コマンドセットを与えられ、先に設定し、指定されたコレクションに格納されています。 宛先がすでに存在する場合は上書きされます。

文法

次のようにRedisのSunionstore基本的なコマンドの構文は次のとおりです。

redis 127.0.0.1:6379> SUNIONSTORE DESTINATION KEY KEY1..KEYN

利用可能なバージョン

> = 1.0.0

戻り値

結果セット内の要素の数。

redis 127.0.0.1:6379> SADD myset1 "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset1 "world"
(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 "bar"
(integer) 1
redis 127.0.0.1:6379> SUNIONSTORE myset myset1 myset2
(integer) 1
redis 127.0.0.1:6379> SMEMBERS myset
1) "bar"
2) "world"
3) "hello"
4) "foo"

Redisのセット(セット)