Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

@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.

3 participants