MemoryStoreSortedMap:GetRangeAsync() can only get 1-100 entries

Reproduction Steps
To reproduce run this code:

local memoryStoreService = game:GetService("MemoryStoreService")
local SortedMap = memoryStoreService:GetSortedMap("test2")
local data = SortedMap:GetRangeAsync(Enum.SortDirection.Descending)

Expected Behavior
According to the Memory Store page (Memory Store) this should return ALL key values in the sorted map if no range is given.
BUT it says the highest value you can give is 200 in the API page though (GetRangeAsync).

I expect if i leave the second parameter blank, it should return ALL key values in the entire sorted map.

Actual Behavior
However in studio when I try to input a range higher than 100 it says this.

If I dont put any value for the second parameter it says:

Issue Area: Engine
Issue Type: Other
Impact: High
Frequency: Constantly
Date First Experienced: 2021-09-23 00:09:00 (-04:00)
Date Last Experienced: 2021-09-26 00:09:00 (-04:00)

2 Likes

This should be fixed now, thank you for reporting it.

2 Likes


It still doesn’t seem to allow me to get all of the key values by leaving the range parameter blank.
image

2 Likes

Same thing is happening to me.

1 Like

We should clarify the documentation. The function allows requesting up to 200 keys at once. If the sorted map has more keys than that, you’ll need to make multiple calls in a loop to retrieve all of them. You can use the exclusiveLowerBound parameter to avoid retrieving keys that were already retrieved in prior iterations as shown in the example below:

local mss = game:GetService("MemoryStoreService")
local map = mss:GetSortedMap("listing_test")

local startFrom = nil
local page = {}

repeat
    page = map:GetRangeAsync(Enum.SortDirection.Ascending, 200, startFrom)
    for _, pair in ipairs(page) do
        print("key = " .. pair.key .. ", value = " .. pair.value)
    end
    if #page > 0 then
        startFrom = page[#page].key
    end
until #page == 0
11 Likes

Ahhh, I see. Thanks for clearing that up.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.