I can't really think of any practical reason why caching this information is necessary. I would honestly loop through the list and run
GetItemInfo() on load (ignoring the returns) to force the game to query the items, then run
GetItemInfo() again on what specific item I need info on when I need it. Saves a lot of trouble in the long run with negligible if any resource impact.
If your list is really long, you may opt to build a queue.
Lua Code:
local ItemQueue={};
local function AddToQueue(itemid)
if #ItemQueue<=0 or not GetItemInfo(itemid) then-- Auto-queries server if this is the first entry, otherwise just adds to queue
table.insert(ItemQueue,itemid);-- Pushes to end of queue
end
end
local QueueFrame=CreateFrame("Frame");
QueueFrame:RegisterEvent("GET_ITEM_INFO_RECEIVED");
QueueFrame:SetScript("OnEvent",function(_,_,itemid)
if ItemQueue[1]==itemid then-- Server responded to query
table.remove(ItemQueue,1);-- Shift queue
while #ItemQueue>0 do-- Loop until empty
if GetItemInfo(ItemQueue[1]) then-- Check if we have data
table.remove(ItemQueue,1);-- Shift queue
else-- Query was sent
break;-- Exit loop
end
end
end
end);
PS: If
GetItemInfoInstant() gets you all the info you need, I'd suggest using that instead as all the data that accesses is on the client, so it doesn't need to query the server.