-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
###
Expected behavior
hrandfieldWithValues(String key, long count)
should return the count equivalent entries in case of a negative (absolute value of count) or a positive count value.
Actual behavior
hrandfieldWithValues(String key, long count)
currently returns a Map<String, String>
which does not account for the duplicates that can be returned(https://redis.io/commands/hrandfield/) when a negative count is given. This results in an inaccurate number (less than the count) of random entries being returned when there is a negative count.
Steps to reproduce:
- Create a Hash Set with size 5
- Call
hrandfieldWithValues(String key, long count)
with a count of -3. - Assert for the size of the result.
Map<String, String> hash = createHash(5);
jedis.hset(KEY, hash);
long count = -3L;
Map<String, String> result = jedis.hrandfieldWithValues(KEY, count);
assertThat(result.size()).isEqualTo(Math.abs(count));