Thread Tools Display Modes
10-31-08, 01:19 PM   #1
Kjado
A Deviate Faerie Dragon
 
Kjado's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 10
Problems with forcing cache entries

I wrote a small addon to add some inscription information to tooltips:
http://www.wowinterface.com/download...rindstone.html

I have my association tables implemented via item IDs instead of names to provide cross-localization support automatically. However, by doing this I need to force all of the inscription-related items (herbs, pigments, and inks) from my tables into the user's cache so later calls to GetItemInfo() do not return nil. After doing some research, I found that the following will force an item into the cache:
Code:
tooltip:SetHyperlink("item:" .. id)
I step through and do this for all of the items I care about for my addon, however, with a fresh cache (by deleting the Cache folder before starting WoW), GetItemInfo() returns nil later in the addon loading stage, even though I am sure to only call it with arguments I know are valid from my tables. The interesting thing is, if I reload the UI via /console reloadui, etc. a couple times immediately afterwards, the errors cease and the addon works properly.

Is there some sort of delay on cache entries that would cause these first couple startup iterations to not find the items in the cache even though they had been set via GameTooltip:SetHyperlink()? Or if this isn't the case, is there a more effective way to force data into the cache for later use?
  Reply With Quote
10-31-08, 04:37 PM   #2
Cirk
A Cobalt Mageweaver
 
Cirk's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 226
Originally Posted by Kjado View Post
I step through and do this for all of the items I care about for my addon, however, with a fresh cache (by deleting the Cache folder before starting WoW), GetItemInfo() returns nil later in the addon loading stage, even though I am sure to only call it with arguments I know are valid from my tables. The interesting thing is, if I reload the UI via /console reloadui, etc. a couple times immediately afterwards, the errors cease and the addon works properly.
Although SetHyperlink will cause the item to be loaded into your local cache, this takes time since it requires a request to the server and response back. Also, apparently the cache is of limited size, so items will "age out" of the cache over time, meaning even if the item is in the cache today, it may not be tomorrow.

What I do for this problem in Lootvalue (which faces similar problems to your addon) is just to keep retrying every 200msec (via OnUpdate) while the tooltip is shown to see if we have the data yet.

(I use 200msec since for most players that means one retry cycle, and 200msec is the Blizz default tooltip update delay anyway).

Hope that helps
-- Cirk
__________________
Cirk's Addons
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Problems with forcing cache entries


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off