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

Feature Request: Basic caching support #35

Open
randomiser opened this issue Dec 1, 2023 · 2 comments
Open

Feature Request: Basic caching support #35

randomiser opened this issue Dec 1, 2023 · 2 comments

Comments

@randomiser
Copy link

Hi Ilya,

It would be really useful to have a simple mechanism to support caching. For example for SQL data that rarely changes but needs to be loaded often within the graph.

Thinking the r.model could be changed to support this with additional methods something like:

// return string | undefined
cacheKey = (context) => undefined;

// return existing data | query
preFetch = (context, query, cacheKey) => query;

// callback to potentially store in cache
postFetch(context, data, cacheKey) {}

With changes to the r.graph to support the above.

Keen to hear any thoughts.

Kind regards,
Matt

@IlyaSemenov
Copy link
Owner

Thanks for the idea. Technically, I suppose this could already be achieved with query callback and then hacking into Objection lifecycle, but simplified first-class support could be worthy. I'll look into this.

@randomiser
Copy link
Author

Thanks! That'd be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants