Quantcast
Cache suggestions - WoWInterface
Thread Tools Display Modes
07-26-17, 11:04 PM   #1
loff93
A Fallenroot Satyr
Join Date: Apr 2017
Posts: 25
Cache suggestions

Hello!

Example of my code:

Code:
local Immerseus_LFR = {
	[1] = 104922; -- Hood of swirling senses
}

Immerseus = {
	 [1] = {unpack(Immerseus_LFR)};
}

Siege_Of_Orgrimmar = {
	[1] = {name = "Immerseus", unpack(Immerseus)};
}
When I click show items, it will go through the list and spawn the item name etc, but when the item isn't cached it won't show up. Currently I don't have a good way that refreshes/grabs all the items it's going to show.
Any suggestions/tips on how to solve this?
I can't have the addon caching every table when you login because it will be too many tables & data in the end (I assume), so a better way would be:
When you click the "raid". Cache the items -> show items.
Or
Have a "Grab Items" button that you click when you want to use the addon maybe(?)

Have used this for single items earlier but not quite sure how to tweak it for the best solution. I might find a good solution once I know the best way to deal with cache in this situation.
Not that experienced with LUA.
Code:
local wait = {}
local cache_writer = CreateFrame('Frame')
cache_writer:RegisterEvent('GET_ITEM_INFO_RECEIVED')
cache_writer:SetScript('OnEvent', function(self, event, ...)
    if event == 'GET_ITEM_INFO_RECEIVED' then
        -- the info is now downloaded and cached
        local itemID = ...
		local name = GetItemInfo(itemID) 
        if wait[itemID] then
			-- do something when ID is recieved
            wait[itemID] = nil
			end
    end
end)
Function to show items:
Code:
 function CreateItemList(Instance, Difficulty, newFrame)

Last edited by loff93 : 07-26-17 at 11:07 PM.
  Reply With Quote
07-27-17, 07:22 PM   #2
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
http://www.wowinterface.com/forums/s...ad.php?t=55352
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill
  Reply With Quote
07-27-17, 07:29 PM   #3
loff93
A Fallenroot Satyr
Join Date: Apr 2017
Posts: 25
Yes, I have read it ofcourse since it's my own thread from April and I have a solution in mind for my current project as written above - but a general answer on whats recommended for my project would be greatly appreciated. I can make things work etc, but I want the addon to be clean, low memory usage etc and I don't feel like I have a very good solution - but it might just be me overthinking it.
Can do my best and share the result, and get some input.
  Reply With Quote
07-28-17, 04:59 AM   #4
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
I am using a check
Lua Code:
  1. if wait == {} then
  2. updatevisibility()
  3. end
to see when all items are ready. I remember it failed sometimes but couldn't reproduce after clearing the cache.
  Reply With Quote
07-28-17, 05:30 AM   #5
loff93
A Fallenroot Satyr
Join Date: Apr 2017
Posts: 25
Originally Posted by Kakjens View Post
I am using a check
Lua Code:
  1. if wait == {} then
  2. updatevisibility()
  3. end
to see when all items are ready. I remember it failed sometimes but couldn't reproduce after clearing the cache.
Cool, thanks for the input
  Reply With Quote
07-28-17, 11:22 AM   #6
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Originally Posted by Kakjens View Post
I am using a check
Lua Code:
  1. if wait == {} then
  2. updatevisibility()
  3. end
to see when all items are ready. I remember it failed sometimes but couldn't reproduce after clearing the cache.
I am pretty sure
Code:
wait=={}
is always false
just test
Lua Code:
  1. local a={}
  2. if a=={} then
  3.     print("Bank Norris is wrong")
  4. else
  5.     print("Bank Norris is correct")
  6. end
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 07-28-17 at 11:24 AM.
  Reply With Quote
07-28-17, 02:40 PM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,929
Explaining why, {}=={} is not doing anything special to compare values in tables. What it does is create two completely different tables and compare their pointers. Since they are exactly two different tables, their pointers are different and this results in false. If you want to check if the table is empty, the most basic way is to call next(wait) and see if it returns nil.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-28-17 at 02:45 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Cache suggestions

Thread Tools
Display Modes

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