Engine Class
MemoryStoreQueue
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
GetSizeAsync(excludeInvisible: boolean):number |
RemoveAsync(id: string):() |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
AddAsync
GetSizeAsync
ReadAsync
ส่งค่ากลับ
ตัวอย่างโค้ด
การใช้ 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()
-- รอให้มีรายการหนึ่งเพื่อทำการประมวลผล
local items, id = queue:ReadAsync(1, false, 30)
-- ตรวจสอบว่ามีรายการถูกดึงมาไหม
if #items > 0 then
-- ทำเครื่องหมายว่ารายการนั้นได้ประมวลผลแล้ว
dataStore:UpdateAsync(items[0], function(data)
data = data or {}
data.processed = 1
return data
end)
-- ลบรายการออกจากคิว
queue:RemoveAsync(id)
end
end)
endRemoveAsync
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การใช้ 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()
-- รอให้มีรายการหนึ่งเพื่อทำการประมวลผล
local items, id = queue:ReadAsync(1, false, 30)
-- ตรวจสอบว่ามีรายการถูกดึงมาไหม
if #items > 0 then
-- ทำเครื่องหมายว่ารายการนั้นได้ประมวลผลแล้ว
dataStore:UpdateAsync(items[0], function(data)
data = data or {}
data.processed = 1
return data
end)
-- ลบรายการออกจากคิว
queue:RemoveAsync(id)
end
end)
end