The screenshot below shows the logs from the code snippet running on a live server.
- A dictionary
{Hello="World"}
isAddAsync()
to the queue withinvisibilityTimeout=0
. - The yellow highlight shows the point where
RemoveAsync()
andReadAsync()
are called. - Despite
RemoveAsync()
being called and no exceptions frompcall()
,ReadAsync()
still returns the same table from the queue.
Code Snippet
local queue: MemoryStoreQueue = game:GetService("MemoryStoreService"):GetQueue("test", 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;
task.spawn(function()
retryer("Read 2", function()
readVal, dataKey = queue:ReadAsync(1, false, 3);
end)
print("TestScript>> Read 2",readVal, dataKey);
for a=1, 10 do
retryer("Remove", function()
queue:RemoveAsync(dataKey);
task.wait(1);
end)
print("TestScript>> Remove", a);
retryer("Read Loop", function()
readVal, dataKey = queue:ReadAsync(1, false, 3);
print("TestScript>> Read Loop", readVal, dataKey);
end)
if readVal == nil then
print("Val is removed!");
break;
end
end
end)
retryer("Read 3", function()
task.wait(1);
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)