Skip to content

Caching? #25

@Krzysiu

Description

@Krzysiu

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions