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: abstract caching helper to request level to make code simpler #3473

Merged
merged 5 commits into from
Jun 19, 2018

Conversation

edbrett
Copy link
Contributor

@edbrett edbrett commented Jun 11, 2018

This is a demo PR to test simplifying the cache methods for the react - redis caching set up. It does the following:

  • Remove react caching provider and all reference to cache
  • Fetches cache on a per request level
  • Returns an additional promise inside the cache method to enable this

@edbrett edbrett added the WIP Any PR that should not be merged to develop label Jun 11, 2018
@edbrett edbrett requested a review from pjosh June 11, 2018 11:23
.then(() => response)
.catch(() => response)
);
return axios.get(`/cache/${key}`).then(cache => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these changes we always do 2 request per request (cache + API) when the key is not saved (it happens because we don't have unlimited space). That's the reason of getting all the cache keys before.
Of course, we can live with that, but it goes against performance directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that was not the goal! The idea was that for each fetch you attempt to get that cache data (using the request as the key). If there is cache then it simply returns and you have the data, if not it gets the data and caches it. I wanted to try it this way to test performance as it might be a couple more fetches but they are very very small fetches only in the case that there isnt cache. And then we dont have to worry about bugs in the componentWillRecieveProps functions of each component which scare me. Now caching is separate from the components. I might have made some mistake in this change so let me check again.

pjosh and others added 4 commits June 18, 2018 16:12

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
feature/rails-cache-keys
@edbrett edbrett merged commit d38e91e into develop Jun 19, 2018
@edbrett edbrett deleted the feature/abstract-cache-to-helper branch June 19, 2018 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Any PR that should not be merged to develop
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants