wikidata icon indicating copy to clipboard operation
wikidata copied to clipboard

Caching?

Open Krzysiu opened this issue 1 year ago • 0 comments

Would be it possible to add save/load response feature? That could serve as caching system -for testing projects that needs a few (or way more) fetches, eventually to manually change data to test edge cases ("what my script will do if this field won't be filled on WD"). And even better for public scripts, with a lot of hits where author could easily cache data for certain time.

I imagine it something like:

if (file_exists('cache.txt') $wikidata->loadString(file_get_contents('cache.txt')); // and loadFile('cache.txt')? That would be rad
else { $wikidata->get('Q12345'); file_put_contents('cache.txt', $wikidata->rawResponse); }

So an additional property, which is filled upon get() method and can be populated with loadString() method (and then processed, as it would be response from curl). Optionally (because one can keep track of it by oneself, not relying on class), a property source to display curl, string or file (in case f proposed loadFile())

Krzysiu avatar Mar 06 '24 15:03 Krzysiu