Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Cache the lookup key #40

Open
xavdid opened this issue Dec 28, 2024 · 1 comment
Open

[REQUEST] Cache the lookup key #40

xavdid opened this issue Dec 28, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@xavdid
Copy link

xavdid commented Dec 28, 2024

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: xavdid/howlongtobeat@5375d74#diff-1af9a3390b92891b019f2dbae92c77ca7d05282003849d5642715613e809ab54R89, if that's useful!

@xavdid xavdid added the enhancement New feature or request label Dec 28, 2024
@xavdid xavdid changed the title [REQUEST] Cache lookup code [REQUEST] Cache the lookup key Dec 28, 2024
@ScrappyCocco
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants