I’m using MemoryStoreSortedMap:GetRangeAsync() for ranked matchmaking, however, I’m having issues with searching for appropriate lower and upper bounds.
For example, I only want to get players that have a rating between 10-20, therefore, my parameters would be:
MemoryStoreSortedMap:GetRangeAsync(Enum.SortDirection.Ascending, 10, "10", "20")
-- I'm only looking for 10 players before we start, in an ascending order.
However, I’m getting an issue with this, and it doesn’t return with the keys that have a value between 10 and 20. Is it because I’m misunderstanding how the exclusivity of lower and upper bounds work here?
Here’s what I’m expecting in return:
[index] = {
["key"] = "userId",
["value"] = rating (integer) -- between 10-20
}
-- 9 more.
But whenever their value doesn’t meet an integer between 10-20, let’s state they have 21, it’d still return me the key of them, although I set the optional bounds. What’s wrong here?
Considering those parameters are optional I’m assuming if the memory store does not have enough entries with values between the two specified bounds then any entry is retrieved instead, regardless of its value.
Solved it! The rating is needed to be implemented in the .key value to be compared by the bounds, hence I had no other choice but to link it with the userId so it doesn’t get overwritten by another player.
Whenever reading the sorted map, it’s important to also pad the boundaries (both work together). If you leave it as 21, and the key’s value is 0021, it won’t be recognised:
MemoryStoreSortedMap:GetRangeAsync(Enum.SortDirection.Ascending, 10, "0021", "0120")
-- returns all the keys that have the rating of 21-120.