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 support for cache in resources #3

Open
cyppan opened this issue May 24, 2016 · 0 comments
Open

Add support for cache in resources #3

cyppan opened this issue May 24, 2016 · 0 comments

Comments

@cyppan
Copy link
Owner

cyppan commented May 24, 2016

I think it's better to implement caching as a dedicated feature instead of composing a DataSource.

Once the oplog and a tailable cursor has been implemented, it's pretty easy to add a long-lived memory cache which would be an atom referencing a map of $resource-$id keys to document futures.
This way requests are de-deduplicated de facto.
In the case of querying several ids at one time, every id can point to a future extracted from the multi-id running future.

A good simplification IMO:

  • when a query is made against ids directly, use the cache directly when possible (otherwise feed it with results).
  • when a query is made using a find specification, get the ordered ids from that query using the datasource directly, and then fetch the corresponding documents from the cache if they exists, else feed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant