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

background update feature #53

Open
klh opened this issue May 27, 2019 · 3 comments
Open

background update feature #53

klh opened this issue May 27, 2019 · 3 comments

Comments

@klh
Copy link

klh commented May 27, 2019

When using throttle &/or cache it would be beneficial to have a
fast return Cache, but update (if possible) Cache in background as a post event.

so instead of (pseudo code):

.get('my/url')
->respond with getFromCache('my/url')

do this:

.get('my/url')
->respond with getFromCache('my/url')
send('my/url')
->updateCache with result from my/url request
@kuitos
Copy link
Owner

kuitos commented May 27, 2019

It prefer to provide the upper ability in your own application but not the underlying library.
duplicated with #52

@klh
Copy link
Author

klh commented May 27, 2019

sure that's a duplicate?'
The intention was to always respond fast, and take the hit on a long loading endpoint in the background - and next request would then have an updated cache item?

so 1 get would be equivalent to:

get->returnFromCache->get->request->updatedCache

@kuitos kuitos removed the duplicate label May 27, 2019
@kuitos
Copy link
Owner

kuitos commented May 27, 2019

Sorry for my mistake.
U could wrap your request method, and makes them do a background forceUpdate after every call.
eg.

async function request() {
  const res  = await http.get('/url');
  http.get('/url', { forceUpdate: true })
  return res
}

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