scholarly icon indicating copy to clipboard operation
scholarly copied to clipboard

Cache query results

Open tigerjack opened this issue 2 years ago • 7 comments

What feature would you like to request? It would be great to have a cache of the results, similarly to what pybliometrics is already doing.

tigerjack avatar Oct 05 '23 21:10 tigerjack

Could you expand a bit more on the use case? Are you suggesting that if you repeat a query, scholarly should return cached results instead of running the query again, or if a query returns results that have been previously returned from a different query (and filled say), it should fill the information from the cached results?

arunkannawadi avatar Nov 07 '23 04:11 arunkannawadi

Could you expand a bit more on the use case? Are you suggesting that if you repeat a query, scholarly should return cached results instead of running the query again, or if a query returns results that have been previously returned from a different query (and filled say), it should fill the information from the cached results?

I guess both of them are valid ideas, but the first seems more immediate. pybliometrics, for example, takes the results from the cache unless the user specifically force an update. I guess there's also an expire date for the cached results, but I am not sure about it.

For the use case, even testing some user scripts often requires a lot of time, since the results should be fetched every time from the web.

tigerjack avatar Nov 07 '23 11:11 tigerjack

OK, having something like a 24-hour expiration for cached results would make sense. I don't have a timeline for this feature, but would welcome a PR from the community.

arunkannawadi avatar Nov 07 '23 15:11 arunkannawadi

It's actually very easy to do this with requests_cache (no changes needed in scholarly)

See the "patching" approach where requests_cache simply monkeypatches all calls to the requests library

https://requests-cache.readthedocs.io/en/stable/#patching

ltalirz avatar Nov 26 '23 23:11 ltalirz

I did this @ltalirz but it didn't work. The cache is installed but no URLs are returned. Did you try this out or have an example to show? Thank you!

Update: I just saw where the requests are happening :)

anapaulagomes avatar Dec 07 '23 11:12 anapaulagomes

Cheers, so it does work for you as well?

ltalirz avatar Dec 07 '23 15:12 ltalirz

No, it doesn’t. I haven’t look further

anapaulagomes avatar Dec 07 '23 18:12 anapaulagomes