PyBites-Open-Source / eatlocal

This package helps users solve PyBites code challenges on their local machine.
MIT License
20 stars 9 forks source link

Speed up eatlocal download bite listing #48

Closed bbelderbos closed 1 week ago

bbelderbos commented 2 weeks ago

The new bite api endpoint is pretty static, we don't even add new bites every week and titles don't change often.

So let's add caching and with requests this is very easy: https://pybitesplatform.com/tips/caching-api-calls

This will make the sub command respond instantly leveraging a local sqlite db, something the user does not even notices.

pybites-search is so fast using this same technique: https://github.com/PyBites-Open-Source/search/blob/main/src/pybites_search/base.py#L26

@rhelmstedter what do you think?

rhelmstedter commented 2 weeks ago

I love it. How long should I set the expiration for, a week?

bbelderbos commented 2 weeks ago

That works for me, do we want a cache refresh flag (basically delete the cache file)

That can be a follow up because addition of bites is not that frequent anyway.

rhelmstedter commented 1 week ago

I didn't see your last comment until afterward. But what I ended up doing was setting the cache to expire after 30 days, but added a --clear-cache flag for the user if needed. I think that is a good in-between. a3b391d

bbelderbos commented 1 week ago

That's perfect, thanks!

bbelderbos commented 1 week ago

implemented https://github.com/PyBites-Open-Source/eatlocal/pull/49