How often does "Request Failed" occur for MemoryStoreQueues?

I’m currently working on a matchmaking system using MemoryStoreService. I’ve noticed, that my API calls fail quite frequently (~1 out of 5 calls). I have <50 calls per player per minute which is way below the limit. The creator dashboard also confirms that I’m not exceeding the limit:

Is the amount of failed request normal or could it be an issue with my code?

2 Likes

Can I see the code? I’ll try and see what’s wrong.

1 Like

I can’t show you the whole code but here’s the two functions I use to get/set the data:

function GetFromMemory(Memory,Key,Retries)
	Retries = Retries or 3
	
	local Attempts = 0
	local Success,Result
	
	while not Success and Attempts < Retries do
		Success,Result = pcall(Memory.GetAsync,Memory,Key)
		Attempts = Attempts + 1
		
		if not Success then
			task.wait(3)
		end
	end
	
	if not Success then
		warn("Error retrieving data: "..Result)
	else
		return Result
	end
end

function SaveToMemory(Memory,Key,Value,ExpirationTime,Retries)
	Retries = Retries or 3

	local Attempts = 0
	local Success,Error

	while not Success and Attempts < Retries do
		Success,Error = pcall(Memory.SetAsync,Memory,Key,Value,ExpirationTime)
		Attempts = Attempts + 1

		if not Success then
			task.wait(2)
		end
	end

	if not Success then
		warn("Error saving data: "..Error)
	else
		return Success
	end
end

And this is how I use :UpdateAsync() :

local PlayerInfo = GetFromMemory(PlayerMemory,Player.UserId,1)

if PlayerInfo and PlayerInfo.Teleported == false then
	local function UpdatePlayerMemory(OldPlayerInfo)
		OldPlayerInfo.Teleported = true
	
		return OldPlayerInfo
	end

	local Success,Error = pcall(function()
		PlayerMemory:UpdateAsync(Player.UserId,UpdatePlayerMemory,7200)
	end)
end