Feature - Rejected Share mall prices across mafia instances

zarqon

Well-known member
There are quite a few commonly-used scripts that search for mall prices on a list of items -- CounterChecker, Universal Recovery, networth.ash, PriceAdvisor, probably EatDrink (haven't used it), to name a few. I also have a few daily utilities that do this -- my daily consumption script, and my "profitable zap" script.

The way mall_price() currently works, it will hit the server once per session per item. This is nice to KoL's servers.

I'm proposing to make it much nicer. If I call mall_price() 4 hours after the first call but in the same session, it uses the cached result. However, if a concurrent instance of mafia calls mall_price() just seconds after the original call, it will still hit the server because it's not in the same session.

Can we share the mallprice cache across mafia instances, making the expiry time-based rather than session-based? If I left mafia unattended for most of the day and came back, I'd want fresh mall prices. Likewise, if I'm running multiple mafia instances I don't need it to hit the server twice just seconds apart. I suggest an expiry time of 2 hours, but that's certainly up for discussion -- it could also be a preference.

This proposal would save literally tens of thousands of server hits. Probably millions, eventually.
 
In the case where you want to prevent a mall_price call if the historical price is recent, can you not use this:
(stolen from CounterChecker.ash)
Code:
item thisitem = $item [whatever];
if (historical_age(thisitem) > 1 || historical_price(thisitem) == 0) mall_price(thisitem);
int itemprice = historical_price(thisitem);
or does that fail for concurrent sessions due to cacheing of mallprices.txt? I'm at work right now, so I can't check...

Of course, that doesn't help with getting prices to update more than once over a very long session. And having mall_price() behave like this by default would be nice.
 

Fluxxdog

Active member
zarqon said:
I'm proposing to make it much nicer. If I call mall_price() 4 hours after the first call but in the same session, it uses the cached result. However, if a concurrent instance of mafia calls mall_price() just seconds after the original call, it will still hit the server because it's not in the same session.
Awesome idea if this can be implemented. I have a consumption script as well that not only checks items but the ingredients as well. Not to mention Bale's OCD script...
In the case where you want to prevent a mall_price call if the historical price is recent, can you not use this:
(stolen from CounterChecker.ash)
Code:
item thisitem = $item [whatever];
if (historical_age(thisitem) > 1 || historical_price(thisitem) == 0) mall_price(thisitem);
int itemprice = historical_price(thisitem);
or does that fail for concurrent sessions due to cacheing of mallprices.txt? I'm at work right now, so I can't check...
Historical_age() returns a float, so if you wanted to check after a couple hours, you could go for:
Code:
if (historical_age(thisitem) > 2.0/24.0 ...
 

Bale

Minion
or does that fail for concurrent sessions due to cacheing of mallprices.txt? I'm at work right now, so I can't check...

Yes, that completely fails for concurrent sessions.

If I run EatDrink for one character and it checks a pile of price data to decide what to do and then I run EatDrink for another character in a second mafia instance it will check all those prices AGAIN even if it compares historical_age() in that way. To make it not check price data for the second character I have to close the first session before starting the second session.
 
Last edited:

Veracity

Developer
Staff member
Just noticed a bot looking at this and was curious.

Since the "cache" that mall_price looks at is actually a set of (multiple) saved search results, not just an integer, I'm not sure how that could be shared across multiple sessions.
 
Top