ItemCache

ItemCache

633 Downloads

This addon does nothing on its own. It is a helper for other addons.  

  

ItemCache remembers data about items when they are loaded. It can be run as an addon so that the cache persists between sessions, or it can be embedded into another addon as a library.  
  
Documentation (WIP)  
  
Example code  
  
local ItemCache = LibStub("ItemCache")  -- Load the library

local hearthstone = ItemCache:Item(6948) -- Returns an Item object for an item with id 6948 (Hearthstone)  
print(hearthstone:GetLink()) -- Returns the item link for the item. Will return nil if the item is not cached (hearthstone probably is!)  

local healingBoots = ItemCache:Item(30680, -26) -- Returns an Item object for Glider's Boots of Healing  
healingBoots:OnCache(function(item)  
  print(item:GetLink()) -- Never returns nil (as long as the item actually exists)  
end) -- Prints the item link as soon as the item is in the cache. Also loads the item if it is not yet cached.  

print(healingBoots:IsCached()) -- Returns true if the boots have been seen before, false otherwise  
print(healingBoots:IsLoaded()) -- Returns true if the boots are currently loaded by the game (GetItemInfo will be populated), false otherwise  
healingBoots:Load() -- Attempts to load the item into memory so that GetItemInfo will be populated  
healingBoots:Cache() -- Same as above but does nothing if the item has already been seen