MemoryStoreQueue

Show Deprecated
Not Creatable
Not Replicated

Provides access to a queue within MemoryStore. A queue is a data structure that provides temporary storage for arbitrary items (up to the maximum item size -- see MemoryStore Limits). Each queue item has a numeric priority: MemoryStore retrieves items with higher priority from the queue first, and it retrieves Items with the same priority in order of addition.

Items in the queue can optionally be set to expire after a certain amount of time. Expired items simply disappear from the queue as if they were never added.

Summary

Methods

Properties

Methods

AddAsync

()
Yields

Parameters

value: Variant
expiration: number
priority: number
Default Value: 0

Returns

()

GetSizeAsync

Yields

Parameters

excludeInvisible: boolean
Default Value: false

Returns

ReadAsync

Yields

Parameters

count: number
allOrNothing: boolean
Default Value: false
waitTimeout: number
Default Value: -1

Returns

Code Samples

Using a MemoryStoreQueue

local MemoryStoreService = game:GetService("MemoryStoreService")
local DataStoreService = game:GetService("DataStoreService")
local queue = MemoryStoreService:GetQueue("PlayerQueue")
local dataStore = DataStoreService:GetDataStore("PlayerStore")
while true do
pcall(function()
-- wait for an item to process
local items, id = queue:ReadAsync(1, false, 30)
-- check if an item was retrieved
if #items > 0 then
-- mark the item as processed
dataStore:UpdateAsync(items[0], function(data)
data = data or {}
data.processed = 1
return data
end)
-- remove the item from the queue
queue:RemoveAsync(id)
end
end)
end

RemoveAsync

()
Yields

Parameters

id: string

Returns

()

Code Samples

Using a MemoryStoreQueue

local MemoryStoreService = game:GetService("MemoryStoreService")
local DataStoreService = game:GetService("DataStoreService")
local queue = MemoryStoreService:GetQueue("PlayerQueue")
local dataStore = DataStoreService:GetDataStore("PlayerStore")
while true do
pcall(function()
-- wait for an item to process
local items, id = queue:ReadAsync(1, false, 30)
-- check if an item was retrieved
if #items > 0 then
-- mark the item as processed
dataStore:UpdateAsync(items[0], function(data)
data = data or {}
data.processed = 1
return data
end)
-- remove the item from the queue
queue:RemoveAsync(id)
end
end)
end

Events