Yang Bodong 1021d248a6 Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297)
New commands:
`HRANDFIELD [<count> [WITHVALUES]]`
`ZRANDMEMBER [<count> [WITHSCORES]]`
Algorithms are similar to the one in SRANDMEMBER.

Both return a simple bulk response when no arguments are given, and an array otherwise.
In case values/scores are requested, RESP2 returns a long array, and RESP3 a nested array.
note: in all 3 commands, the only option that also provides random order is the one with negative count.

Changes to SRANDMEMBER
* Optimization when count is 1, we can use the more efficient algorithm of non-unique random
* optimization: work with sds strings rather than robj

Other changes:
* zzlGetScore: when zset needs to convert string to double, we use safer memcpy (in
  case the buffer is too small)
* Solve a "bug" in SRANDMEMBER test: it intended to test a positive count (case 3 or
  case 4) and by accident used a negative count

Co-authored-by: xinluton <xinluton@qq.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
2021-01-29 10:47:28 +02:00
..
2020-11-09 21:48:56 -08:00
2020-04-24 17:00:03 -07:00
2020-04-24 17:11:21 -07:00
2021-01-04 17:02:57 +02:00
2018-07-03 18:19:46 +02:00
2021-01-26 09:45:53 +08:00
2019-02-24 21:38:15 +01:00
2020-11-08 08:32:38 +02:00
2021-01-04 17:02:57 +02:00
2020-10-27 15:04:18 +02:00
2020-05-05 23:35:08 -04:00
2020-09-29 15:52:13 +03:00
2019-11-19 17:23:47 +08:00
2021-01-04 17:02:57 +02:00
2021-01-04 17:02:57 +02:00
2019-10-02 11:30:20 +02:00
2020-07-24 14:40:19 +08:00
2021-01-28 18:17:39 +02:00
2021-01-28 18:17:39 +02:00
2021-01-04 17:02:57 +02:00
2021-01-28 16:19:43 +02:00
2021-01-28 16:19:43 +02:00
2020-07-21 08:13:05 +03:00
2020-12-13 11:11:29 +02:00
2021-01-18 11:37:05 +02:00
2021-01-18 11:37:05 +02:00