HowLongToBeat-PythonAPI icon indicating copy to clipboard operation
HowLongToBeat-PythonAPI copied to clipboard

[REQUEST] Cache the lookup key

Open xavdid opened this issue 1 year ago • 1 comments

Describe what change or improvement would you like

Because we're reading this data unofficially, it might be kind to cache the extracted lookup key in the class. Right now the code fetches the key repeatedly (sometimes multiple times per operation), which probably causes extra load.

When this package is used on a server, it's probably as a long-lived class. Since it doesn't change often, you could store the key on the class instance until you get a 404 (which could either be real, or a signal that the url has been updated).

I did a similar approach here: https://github.com/xavdid/howlongtobeat/commit/5375d74481726b94c457e1828d48814c40a591d7#diff-1af9a3390b92891b019f2dbae92c77ca7d05282003849d5642715613e809ab54R89, if that's useful!

xavdid avatar Dec 28 '24 22:12 xavdid

You can provide a PR with your change so we can check it out and discuss it! At the time I thought that caching was not a good idea because you have no idea when the key is gonna change and so retrying seemed a bit complex to me (is it failing because the key expired or because something else changed?) If you don't think this is a problem you can provide an implementation

ScrappyCocco avatar Dec 29 '24 11:12 ScrappyCocco

Closed for no response and because I don't think caching is a good idea

ScrappyCocco avatar May 12 '25 10:05 ScrappyCocco