เรียนรู้
Engine Class
MemoryStoreQueue
ไม่สามารถสร้าง
ไม่ซ้ำ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
AddAsync(value: Variant,expiration: number,priority: number):()
GetSizeAsync(excludeInvisible: boolean):number
ReadAsync(count: number,allOrNothing: boolean,waitTimeout: number):Tuple
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
AddAsync
ผลตอบแทน
ความสามารถ: DataStore
MemoryStoreQueue:AddAsync(
value:Variant, expiration:number, priority:number
):()
พารามิเตอร์
value:Variant
expiration:number
priority:number
ค่าเริ่มต้น: 0
ส่งค่ากลับ
()

GetSizeAsync
ผลตอบแทน
ความสามารถ: DataStore
MemoryStoreQueue:GetSizeAsync(excludeInvisible:boolean):number
พารามิเตอร์
excludeInvisible:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ

ReadAsync
ผลตอบแทน
ความสามารถ: DataStore
MemoryStoreQueue:ReadAsync(
count:number, allOrNothing:boolean, waitTimeout:number
พารามิเตอร์
count:number
allOrNothing:boolean
ค่าเริ่มต้น: false
waitTimeout:number
ค่าเริ่มต้น: -1
ส่งค่ากลับ
ตัวอย่างโค้ด
การใช้ 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

RemoveAsync
ผลตอบแทน
ความสามารถ: DataStore
MemoryStoreQueue:RemoveAsync(id:string):()
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การใช้ 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

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ