Memory Store Queue doesn't properly dequeue?

So I have a MemoryStoreQueue with invisibilityTimeout set to 0. And the issue is that even after the RemoveAsync is called, the queue still contains the item. I use a new queue every test, did I do something wrong?

Steps
Read 0 is empty, Correct
Add, adds an item to queue
Read 1, has 1 item, correct
Read 2, has 1 item, correct
Remove, remove using key provided by Read 2
Read 3, sure, has 1 item, maybe remove async isn’t done
Read 4, Still has 1 item??
task.wait(1)
Read 5, Okay, item is still there and not removed

Output:

Below is my test code.

--!strict
print("TestScript!")


local queue: MemoryStoreQueue = game:GetService("MemoryStoreService"):GetQueue("test3", 0);

local testVal1: {any} = {Hello="World"};

local function retryer(id: string, func)
	for a=1, 8 do
		local s, e = pcall(func);
		if s == true then
			break;
		end
		print("TestScript>> Retrying (",id,") ",a,"/8: ", e);
		task.wait((a-1)^2);
	end
end

retryer("Clear all", function() 
	local d, k = queue:ReadAsync(99, false, 3);
	if k ~= nil then
		queue:RemoveAsync(k);
	end
	print("TestScript>> Clear all read", d, k);
end)

task.wait(1);

retryer("Read 0", function() 
	print("TestScript>> Read 0",queue:ReadAsync(1, false, 3));
end)

retryer("Add", function() 
	queue:AddAsync(testVal1, 300)
	print("TestScript>> Add", testVal1);
end)

retryer("Read 1", function() 
	print("TestScript>> Read 1",queue:ReadAsync(1, false, 3));
end)

local readVal, dataKey;
retryer("Read 2", function() 
	readVal, dataKey = queue:ReadAsync(1, false, 3);
end)
print("TestScript>> Read 2",readVal, dataKey);


task.spawn(function()
	retryer("Remove", function() 
		queue:RemoveAsync(dataKey);
	end)
	print("TestScript>> Remove")
	retryer("Read 4", function() 
		print("TestScript>> Read 4",queue:ReadAsync(1, false, 3));
	end)
end)
retryer("Read 3", function() 
	print("TestScript>> Read 3",queue:ReadAsync(1, false, 3));
end)

task.wait(1);
retryer("Read 5", function() 
	print("TestScript>> Read 5",queue:ReadAsync(1, false, 3));
end)

Can you try adding a task.wait() to the retryer function? Just to give the system to process the RemoveAsync request. Since MemoryStoreQueue functions are asynchronous, you’ve got some functions that aren’t waiting for the removal process to be completed.

retryer("Read 3", function()
    task.wait(1) -- Wait for 1 second to give time for the RemoveAsync to take effect
    print("TestScript>> Read 3", queue:ReadAsync(1, false, 3));
end)

Also you don’t need to put ; after every statement!

Doesn’t change much I’m afraid, as long as the invisibilityTimeout = 0, I can’t remove anything from the queue it seems.

Appears that I missed this part,

So now I guess I’m just looking for a feature request. Ability to ReadAsync from MemoryStoreQueue without it getting marked as Invisible

1 Like

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