學習
引擎類別
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 是我們在美國及其他國家地區的部分註冊與未註冊商標。