MemoryStoreHashMap:ListItemsAsync() returns 21 pages even though no data is stored

Consider the following code:

local MemoryStoreService = game:GetService("MemoryStoreService")

local testHashMap = MemoryStoreService:GetHashMap("HashMap2")
local pages = testHashMap:ListItemsAsync(200)

local count = 0
local page

while true do
	count += 1
	page = pages:GetCurrentPage()
	print(count, page)
	if pages.IsFinished == true then
		break
	end
	pages:AdvanceToNextPageAsync()
end

So even though there is no data stored in the hash map, it still returns 21 blank pages. Now in reading the documentation here, here, and here, it says the API request units are [# of partitions scanned] + [# of items returned] for MemoryStoreHashMap:ListItemsAsync(). Now I have no idea how many partitions were scanned, but I am assuming that the number of items returns is the number of pages. On the other end of this in the live game, a server is writing to the same hash map once every 10 seconds…since the MemoryStoreHashMap:SetAsync() function takes two units (minimum), that would be 12 units minimum per game server. The lobby server is calling MemoryStoreHashMap:ListItemsAsync() every 10 seconds, So with 21 items returned on a blank hashmap every 10 seconds that would be 126 units per minute. So the total between two servers would be 138 total units for the API call per minute. Also, the maximum API request quota per minute is 1000 + 100 * [# of players] which would make the ceiling for two players to be 1200 units per minute.

So why after the second or third iteration I’m getting messages about throttling?

When I look at the memory store data on the creator hub, it breaks out the page operations of getting the data as shown below:

As one can see in the graphs, the numbers do not add up. One has it pushing the limit and the other one isn’t even at 30 requests. So which one is it?

3 Likes