As Redis Cluster is widely used, I have to make a note here that:
mget
does guarantee order in Redis Standalone mode like @Sergio's answer said
But in Redis Cluster, it's the client library that determines the order of the result. And apparently some of them do not make the guarantee, eg, vert.x redis client. From the source code:
addReducer(MGET, list -> {
int total = 0;
for (Response resp : list) {
total += resp.size();
}
MultiType multi = MultiType.create(total, false);
for (Response resp : list) {
for (Response child : resp) {
multi.add(child);
}
}
return multi;
});
We can see it simply merges mget
result from every node and thus no guarantee on order is provided here.