@@ -2351,19 +2351,224 @@ public function xtrim(string $key, int $maxlen, bool $approx = false, bool $mini
23512351
23522352 public function zAdd (string $ key , array |float $ score_or_options , mixed ...$ more_scores_and_mems ): Redis |int |false ;
23532353
2354+ /**
2355+ * Return the number of elements in a sorted set.
2356+ *
2357+ * @see https://redis.io/commands/zcard
2358+ *
2359+ * @param string $key The sorted set to retreive cardinality from.
2360+ *
2361+ * @return Redis|int|false The number of elements in the set or false on failure
2362+ *
2363+ * <code>
2364+ * <?php
2365+ * $redis = new Redis(['host' => 'localhost']);
2366+ *
2367+ * $redis->del('zs');
2368+ * $redis->zAdd('zs', 0, 'a', 1, 'b', 2, 'c');
2369+ *
2370+ * // count(['a', 'b', 'c']) == 3
2371+ * $redis->zCard('zs');
2372+ * ?>
2373+ * </code>
2374+ */
23542375 public function zCard (string $ key ): Redis |int |false ;
23552376
2356- public function zCount (string $ key , string $ start , string $ end ): Redis |int |false ;
2377+ /**
2378+ * Count the number of members in a sorted set with scores inside a provided range.
2379+ *
2380+ * @see https://redis.io/commands/zcount
2381+ *
2382+ * @param string $key The sorted set to check.
2383+ * @param string $min The minimum score to include in the count
2384+ * @param string $max The maximum score to include in the count
2385+ *
2386+ * NOTE: In addition to a floating point score you may pass the special values of '-inf' and
2387+ * '+inf' meaning negative and positive infinity, respectively.
2388+ *
2389+ * <code>
2390+ * <?php
2391+ * $redis = new Redis(['host' => 'localhost']);
2392+ *
2393+ * $redis->del('fruit-rankings');
2394+ * $redis->zadd('fruit-rankings', -99, 'tomato', 50, 'apple', 60, 'pear', 85, 'mango');
2395+ *
2396+ * // count(['apple', 'oear', 'mango']) == 3
2397+ * $redis->zCount('fruit-rankings', '0', '+inf');
2398+ *
2399+ * // count(['apple', 'pear']) == 2
2400+ * $redis->zCount('fruit-rankings', 50, 60);
2401+ *
2402+ * // count(['tomato']) == 1
2403+ * $redis->zCount('fruit-rankings', '-inf', 0);
2404+ * ?>
2405+ * </code>
2406+ */
2407+ public function zCount (string $ key , string $ start , string $ end ): Redis |int |false ;
2408+
2409+ /**
2410+ * Create or increment the score of a member in a Redis sorted set
2411+ *
2412+ * @see https://redis.io/commands/zincrby
2413+ *
2414+ * @param string $key The sorted set in question.
2415+ * @param float $value How much to increment the score.
2416+ *
2417+ * @return Redis|float|false The new score of the member or false on failure.
23572418
2419+ * <code>
2420+ * <?php
2421+ * $redis = new Redis(['host' => 'localhost']);
2422+ *
2423+ * $redis->del('zs');
2424+ * $redis->zAdd('zs', 0, 'apples', 2, 'bananas');
2425+ *
2426+ * // 2 + 5.0 == 7
2427+ * print_r($redis->zIncrBy('zs', 5.0, 'bananas'));
2428+ *
2429+ * // new element so 0 + 2.0 == 2
2430+ * print_r($redis->zIncrBy('zs', 2.0, 'eggplants'));
2431+ * ?>
2432+ * </code>
2433+ */
23582434 public function zIncrBy (string $ key , float $ value , mixed $ member ): Redis |float |false ;
23592435
2436+ /**
2437+ * Count the number of elements in a sorted set whos members fall within the provided
2438+ * lexographical range.
2439+ *
2440+ * @see https://redis.io/commands/zlexcount
2441+ *
2442+ * @param string $key The sorted set to check.
2443+ * @param string $min The minimum matching lexographical string
2444+ * @param string $max The maximum matching lexographical string
2445+ *
2446+ * @return Redis|int|false The number of members that fall within the range or false on failure.
2447+ *
2448+ * <code>
2449+ * <?php
2450+ * $redis = new Redis(['host' => 'localhost']);
2451+ *
2452+ * $redis->del('captains');
2453+ * $redis->zAdd('captains', 0, 'Janeway', 0, 'Kirk', 0, 'Picard', 0, 'Sisko', 0, 'Archer');
2454+ *
2455+ * count(['Archer', 'Janeway', 'Kirk', 'Picard']) == 4
2456+ * $redis->zLexCount('captains', '[A', '[S');
2457+ *
2458+ * count(['Kirk', 'Picard']) == 2
2459+ * $redis->zRangeByLex('captains', '[A', '[S', 2, 2);
2460+ * ?>
2461+ * </code>
2462+ *
2463+ */
23602464 public function zLexCount (string $ key , string $ min , string $ max ): Redis |int |false ;
23612465
2362- public function zMscore (string $ key , string $ member , string ...$ other_members ): Redis |array |false ;
2466+ /**
2467+ * Retreive the score of one or more members in a sorted set.
2468+ *
2469+ * @see https://redis.io/commands/zmscore
2470+ *
2471+ * @param string $key The sorted set
2472+ * @param mixed $member The first member to return the score from
2473+ * @param mixed $other_members One or more additional members to return the scores of.
2474+ *
2475+ * @return Redis|array|false An array of the scores of the requested elements.
2476+ *
2477+ * <code>
2478+ * <?php
2479+ * $redis = new Redis(['host' => 'localhost']);
2480+ *
2481+ * $redis->del('zs');
2482+ *
2483+ * $redis->zAdd('zs', 0, 'zero', 1, 'one', 2, 'two', 3, 'three');
2484+ *
2485+ * // array(2) {
2486+ * // [0]=>
2487+ * // float(0)
2488+ * // [1]=>
2489+ * // float(2)
2490+ * // }
2491+ * $redis->zMScore('zs', 'zero', 'two');
2492+ *
2493+ * // array(2) {
2494+ * // [0]=>
2495+ * // float(1)
2496+ * // [1]=>
2497+ * // bool(false)
2498+ * // }
2499+ * $redis->zMScore('zs', 'one', 'not-a-member');
2500+ * ?>
2501+ * </code>
2502+ */
2503+ public function zMscore (string $ key , mixed $ member , mixed ...$ other_members ): Redis |array |false ;
23632504
2364- public function zPopMax (string $ key , int $ value = null ): Redis |array |false ;
2505+ /**
2506+ * Pop one or more of the highest scoring elements from a sorted set.
2507+ *
2508+ * @see https://redis.io/commands/zpopmax
2509+ *
2510+ * @param string $key The sorted set to pop elements from.
2511+ * @param int $count An optional count of elements to pop.
2512+ *
2513+ * @return Redis|array|false All of the popped elements with scores or false on fialure.
2514+ *
2515+ * <code>
2516+ * <?php
2517+ * $redis = new Redis(['host' => 'localhost']);
2518+ *
2519+ * $redis->del('zs');
2520+ * $redis->zAdd('zs', 0, 'zero', 1, 'one', 2, 'two', 3, 'three');
2521+ *
2522+ * // Array
2523+ * // (
2524+ * // [three] => 3
2525+ * // )
2526+ * print_r($redis->zPopMax('zs'));
2527+ *
2528+ * // Array
2529+ * // (
2530+ * // [two] => 2
2531+ * // [one] => 1
2532+ * // )
2533+ * print_r($redis->zPopMax('zs', 2));
2534+ * ?>
2535+ * </code>
2536+ */
2537+ public function zPopMax (string $ key , int $ count = null ): Redis |array |false ;
23652538
2366- public function zPopMin (string $ key , int $ value = null ): Redis |array |false ;
2539+ /**
2540+ * Pop one or more of the lowest scoring elements from a sorted set.
2541+ *
2542+ * @see https://redis.io/commands/zpopmin
2543+ *
2544+ * @param string $key The sorted set to pop elements from.
2545+ * @param int $count An optional count of elements to pop.
2546+ *
2547+ * @return Redis|array|false The popped elements with their scores or false on failure.
2548+ *
2549+ * <code>
2550+ * <?php
2551+ * $redis = new Redis(['host' => 'localhost']);
2552+ *
2553+ * $redis->del('zs');
2554+ * $redis->zAdd('zs', 0, 'zero', 1, 'one', 2, 'two', 3, 'three');
2555+ *
2556+ * // Array
2557+ * // (
2558+ * // [zero] => 0
2559+ * // )
2560+ * $redis->zPopMin('zs');
2561+ *
2562+ * // Array
2563+ * // (
2564+ * // [one] => 1
2565+ * // [two] => 2
2566+ * // )
2567+ * $redis->zPopMin('zs', 2);
2568+ * ?>
2569+ * </code>
2570+ */
2571+ public function zPopMin (string $ key , int $ count = null ): Redis |array |false ;
23672572
23682573 /**
23692574 * Retrieve a range of elements of a sorted set between a start and end point.
@@ -2402,6 +2607,44 @@ public function zPopMin(string $key, int $value = null): Redis|array|false;
24022607 */
24032608 public function zRange (string $ key , mixed $ start , mixed $ end , array |bool |null $ options = null ): Redis |array |false ;
24042609
2610+ /**
2611+ * Retrieve a range of elements from a sorted set by legographical range.
2612+ *
2613+ * @see https://redis.io/commands/zrangebylex
2614+ *
2615+ * @param string $key The sorted set to retreive elements from
2616+ * @param string $min The minimum legographical value to return
2617+ * @param string $max The maximum legographical value to return
2618+ * @param int $offset An optional offset within the matching values to return
2619+ * @param int $count An optional count to limit the replies to (used in conjunction with offset)
2620+ *
2621+ * @return Redis|array|false An array of matching elements or false on failure.
2622+ *
2623+ * <code>
2624+ * <?php
2625+ * $redis = new Redis(['host' => 'localhost']);
2626+ *
2627+ * $redis->del('captains');
2628+ * $redis->zAdd('captains', 0, 'Janeway', 0, 'Kirk', 0, 'Picard', 0, 'Sisko', 0, 'Archer');
2629+ *
2630+ * // Array
2631+ * // (
2632+ * // [0] => Archer
2633+ * // [1] => Janeway
2634+ * // [2] => Kirk
2635+ * // [3] => Picard
2636+ * // )
2637+ * $redis->zRangeByLex('captains', '[A', '[S');
2638+ *
2639+ * // Array
2640+ * // (
2641+ * // [0] => Kirk
2642+ * // [1] => Picard
2643+ * // )
2644+ * $redis->zRangeByLex('captains', '[A', '[S', 2, 2);
2645+ * ?>
2646+ * </code>
2647+ */
24052648 public function zRangeByLex (string $ key , string $ min , string $ max , int $ offset = -1 , int $ count = -1 ): Redis |array |false ;
24062649
24072650 /**
0 commit comments