Can MemoryStore requests be nested?

Hi guys.
I have matchmaking system, and I suspect that it works not like needed.
One of my theories why this can occur is me nesting MemoryStore request inside another one, like this:

local Data, SortKey = MemoryStore:UpdateAsync(QueueKey, function(Data, SortKey)
	if (#Data.Players >= ServerSizePlayerAmount[ServerSize] or Data.Timeout - DateTime.now().UnixTimestamp <= 0) and not Data.Server then
		local ServerCode, ServerId = TeleportService:ReserveServer(IsDevPlace and 16981323188 or 100581820520321)
		Data.Server = ServerCode
		SortKey = -1
		local Repeats = 5
		repeat
			local Success, Error = pcall(function()
				return ReservedServersMS:UpdateAsync(tostring(ServerId), function(ServerData)
					if not ServerData then
						ServerData = {}
						ServerData.Gamemode = Gamemode
						ServerData.Players = #Data.Players
						ServerData.QueueId = QueueKey
						ServerData.ServerSize = ServerSize
						return ServerData
					end
				end, 300)
			end)
			if not Success then
				task.wait(2^(5-Repeats))
			end
			Repeats -= 1
		until Success or Repeats <= 0
		return Data, SortKey
	end
	return nil
end, 3600)

(I know that it’s messy, I’m fixing that)

1 Like

I know that DataStore UpdateAsyncs are not allowed to yield. I would imagine the same is true for MemoryStores. However, I would also suspect it to throw an error if that is the case.

1 Like