diff --git a/src/t_hash.c b/src/t_hash.c index d0f81c0d7..c640c7ca2 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -1046,7 +1046,7 @@ void hrandfieldWithCountCommand(client *c, long l, int withvalues) { /* Remove random elements to reach the right count. */ while (size > count) { dictEntry *de; - de = dictGetRandomKey(d); + de = dictGetFairRandomKey(d); dictUnlink(d,dictGetKey(de)); sdsfree(dictGetKey(de)); sdsfree(dictGetVal(de)); diff --git a/src/t_set.c b/src/t_set.c index 8239662aa..383d0c692 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -754,7 +754,7 @@ void srandmemberWithCountCommand(client *c) { /* Remove random elements to reach the right count. */ while (size > count) { dictEntry *de; - de = dictGetRandomKey(d); + de = dictGetFairRandomKey(d); dictUnlink(d,dictGetKey(de)); sdsfree(dictGetKey(de)); dictFreeUnlinkedEntry(d,de); diff --git a/src/t_zset.c b/src/t_zset.c index 25c48c2be..26a65baae 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -4159,7 +4159,7 @@ void zrandmemberWithCountCommand(client *c, long l, int withscores) { /* Remove random elements to reach the right count. */ while (size > count) { dictEntry *de; - de = dictGetRandomKey(d); + de = dictGetFairRandomKey(d); dictUnlink(d,dictGetKey(de)); sdsfree(dictGetKey(de)); dictFreeUnlinkedEntry(d,de);