@@ -949,18 +949,177 @@ public function role(): mixed;
949949 */
950950 public function rpoplpush (string $ srckey , string $ dstkey ): Redis |string |false ;
951951
952+ /**
953+ * Add one or more values to a Redis SET key.
954+ *
955+ * @see https://redis.io/commands/sadd
956+
957+ * @param string $key The key name
958+ * @param mixed $member A value to add to the set.
959+ * @param mixed $other_members One or more additional values to add
960+ *
961+ * @return Redis|int|false The number of values added to the set.
962+ *
963+ * <code>
964+ * <?php
965+ * $redis = new Redis(['host' => 'localhost']);
966+ *
967+ * $redis->del('myset');
968+ *
969+ * var_dump($redis->sadd('myset', 'foo', 'bar', 'baz'));
970+ * var_dump($redis->sadd('myset', 'foo', 'new'));
971+ *
972+ * // --- OUTPUT ---
973+ * // int(3)
974+ * // int(1)
975+ * ?>
976+ * </code>
977+ */
952978 public function sAdd (string $ key , mixed $ value , mixed ...$ other_values ): Redis |int |false ;
953979
980+ /**
981+ * Add one ore more values to a Redis SET key. This is an alternative to Redis::sadd() but
982+ * instead of being variadic, takes a single array of values.
983+ *
984+ * @see https://redis.io/commands/sadd
985+ * @see Redis::sadd()
986+ *
987+ * @param string $key The set to add values to.
988+ * @param array $values One or more members to add to the set.
989+ * @return Redis|int|false The number of members added to the set.
990+ *
991+ * </code>
992+ * <?php
993+ * $redis = new Redis(['host' => 'localhost']);
994+ *
995+ * $redis->del('myset');
996+ *
997+ * var_dump($redis->sAddArray('myset', ['foo', 'bar', 'baz']));
998+ * var_dump($redis->sAddArray('myset', ['foo', 'new']));
999+ *
1000+ * // --- OUTPUT ---
1001+ * // int(3)
1002+ * // int(1)
1003+ * ?>
1004+ * </code>
1005+ */
9541006 public function sAddArray (string $ key , array $ values ): int ;
9551007
1008+ /**
1009+ * Given one or more Redis SETS, this command returns all of the members from the first
1010+ * set that are not in any subsequent set.
1011+ *
1012+ * @see https://redis.io/commands/sdiff
1013+ *
1014+ * @param string $key The first set
1015+ * @param string $other_keys One or more additional sets
1016+ *
1017+ * @return Redis|array|false Returns the elements from keys 2..N that don't exist in the
1018+ * first sorted set, or false on failure.
1019+ *
1020+ * <code>
1021+ * <?php
1022+ * $redis = new Redis(['host' => 'localhost']);
1023+ *
1024+ * $redis->pipeline()
1025+ * ->del('set1', 'set2', 'set3')
1026+ * ->sadd('set1', 'apple', 'banana', 'carrot', 'date')
1027+ * ->sadd('set2', 'carrot')
1028+ * ->sadd('set3', 'apple', 'carrot', 'eggplant')
1029+ * ->exec();
1030+ *
1031+ * // NOTE: 'banana' and 'date' are in set1 but none of the subsequent sets.
1032+ * var_dump($redis->sdiff('set1', 'set2', 'set3'));
1033+ *
1034+ * // --- OUTPUT ---
1035+ * array(2) {
1036+ * [0]=>
1037+ * string(6) "banana"
1038+ * [1]=>
1039+ * string(4) "date"
1040+ * }
1041+ * ?>
1042+ */
9561043 public function sDiff (string $ key , string ...$ other_keys ): Redis |array |false ;
9571044
1045+ /**
1046+ * This method performs the same operation as SDIFF except it stores the resulting diff
1047+ * values in a specified destination key.
1048+ *
1049+ * @see https://redis.io/commands/sdiffstore
1050+ * @see Redis::sdiff()
1051+ *
1052+ * @param string $dst The key where to store the result
1053+ * @param string $key The first key to perform the DIFF on
1054+ * @param string $other_keys One or more additional keys.
1055+ *
1056+ * @return Redis|int|false The number of values stored in the destination set or false on failure.
1057+ */
9581058 public function sDiffStore (string $ dst , string $ key , string ...$ other_keys ): Redis |int |false ;
9591059
1060+ /**
1061+ * Given one or more Redis SET keys, this command will return all of the elements that are
1062+ * in every one.
1063+ *
1064+ * @see https://redis.io/commands/sinter
1065+ *
1066+ * @param string $key The first SET key to intersect.
1067+ * @param string $other_keys One or more Redis SET keys.
1068+ *
1069+ * <code>
1070+ * <?php
1071+ *
1072+ * $redis = new Redis(['host' => 'localhost']);
1073+ *
1074+ * $redis->pipeline()
1075+ * ->del('alice_likes', 'bob_likes', 'bill_likes')
1076+ * ->sadd('alice_likes', 'asparagus', 'broccoli', 'carrot', 'potato')
1077+ * ->sadd('bob_likes', 'asparagus', 'carrot', 'potato')
1078+ * ->sadd('bill_likes', 'broccoli', 'potato')
1079+ * ->exec();
1080+ *
1081+ * // NOTE: 'potato' is the only value in all three sets
1082+ * var_dump($redis->sinter('alice_likes', 'bob_likes', 'bill_likes'));
1083+ *
1084+ * // --- OUTPUT ---
1085+ * // array(1) {
1086+ * // [0]=>
1087+ * // string(6) "potato"
1088+ * // }
1089+ * ?>
1090+ * </code>
1091+ */
9601092 public function sInter (array |string $ key , string ...$ other_keys ): Redis |array |false ;
9611093
9621094 public function sintercard (array $ keys , int $ limit = -1 ): Redis |int |false ;
9631095
1096+ /**
1097+ * Perform the intersection of one or more Redis SETs, storing the result in a destination
1098+ * key, rather than returning them.
1099+ *
1100+ * @see https://redis.io/commands/sinterstore
1101+ * @see Redis::sinter()
1102+ *
1103+ * @param array|string $key_or_keys Either a string key, or an array of keys (with at least two
1104+ * elements, consisting of the destination key name and one
1105+ * or more source keys names.
1106+ * @param string $other_keys If the first argument was a string, subsequent arguments should
1107+ * be source key names.
1108+ *
1109+ * @return Redis|int|false The number of values stored in the destination key or false on failure.
1110+ *
1111+ * <code>
1112+ * <?php
1113+ * $redis = new Redis(['host' => 'localhost']);
1114+ *
1115+ * // OPTION 1: A single array
1116+ * $redis->sInterStore(['dst', 'src1', 'src2', 'src3']);
1117+ *
1118+ * // OPTION 2: Variadic
1119+ * $redis->sInterStore('dst', 'src1', 'src'2', 'src3');
1120+ * ?>
1121+ * </code>
1122+ */
9641123 public function sInterStore (array |string $ key , string ...$ other_keys ): Redis |int |false ;
9651124
9661125 public function sMembers (string $ key ): Redis |array |false ;
@@ -973,8 +1132,59 @@ public function sPop(string $key, int $count = 0): Redis|string|array|false;
9731132
9741133 public function sRandMember (string $ key , int $ count = 0 ): Redis |string |array |false ;
9751134
1135+ /**
1136+ * Returns the union of one or more Redis SET keys.
1137+ *
1138+ * @see https://redis.io/commands/sunion
1139+ *
1140+ * @param string $key The first SET to do a union with
1141+ * @param string $other_keys One or more subsequent keys
1142+ *
1143+ * @return Redis|array|false The union of the one or more input sets or false on failure.
1144+ *
1145+ * <code>
1146+ * <?php
1147+ * $redis = new Redis(['host' => 'localhost']);
1148+ *
1149+ * $redis->pipeline()
1150+ * ->del('set1', 'set2', 'set3')
1151+ * ->sadd('set1', 'apple', 'banana', 'carrot')
1152+ * ->sadd('set2', 'apple', 'carrot', 'fish')
1153+ * ->sadd('set3', 'carrot', 'fig', 'eggplant');
1154+ *
1155+ * var_dump($redis->sunion('set1', 'set2', 'set3'));
1156+ *
1157+ * // --- OPUTPUT ---
1158+ * // array(5) {
1159+ * // [0]=>
1160+ * // string(6) "banana"
1161+ * // [1]=>
1162+ * // string(5) "apple"
1163+ * // [2]=>
1164+ * // string(4) "fish"
1165+ * // [3]=>
1166+ * // string(6) "carrot"
1167+ * // [4]=>
1168+ * // string(8) "eggplant"
1169+ * // }
1170+ * ?>
1171+ * </code>
1172+ */
9761173 public function sUnion (string $ key , string ...$ other_keys ): Redis |array |false ;
9771174
1175+ /**
1176+ * Perform a union of one or more Redis SET keys and store the result in a new set
1177+ *
1178+ * @see https://redis.io/commands/sunionstore
1179+ * @see Redis::sunion()
1180+ *
1181+ * @param string $dst The destination key
1182+ * @param string $key The first source key
1183+ * @param string $other_keys One or more additional source keys
1184+ *
1185+ * @return Redis|int|false The number of elements stored in the destination SET or
1186+ * false on failure.
1187+ */
9781188 public function sUnionStore (string $ dst , string $ key , string ...$ other_keys ): Redis |int |false ;
9791189
9801190 public function save (): bool ;
0 commit comments