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

Add caching support for external data files #94

Merged
merged 2 commits into from
Aug 11, 2021
Merged

Add caching support for external data files #94

merged 2 commits into from
Aug 11, 2021

Conversation

danharrin
Copy link
Contributor

Currently, Sushi models are only cached when the $rows property is used. This is because the alternative is usually to return data from an API using getRows(), and caching would mean this data could be out of date.

This PR introduces support to override that behaviour.

First of all, instead of only checking the model file for its last updated timestamp, return a different file path from getDataPath(). I frequently like to store Sushi data in config / CSV files instead and return from getRows(), and this feature allows the cache to know when it is out of date.

To allow these external sources to be cached, I've also introduced the isCached() method. This allows you to enable the cache at will when using getRows(), while preserving original behaviour.

Thanks!

@calebporzio calebporzio merged commit b7c958b into calebporzio:master Aug 11, 2021
@danharrin danharrin deleted the patch-1 branch August 11, 2021 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants