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

specify a config param to control updating cache when a page is not found #225

Open
gpenghe opened this issue Jul 11, 2018 · 2 comments
Open

Comments

@gpenghe
Copy link

gpenghe commented Jul 11, 2018

Expected behaviour

  • Don't update the cache again if the last update happens within a certain period of time, or
  • Just tell the user the command (page) doesn't exist and quit, since it's a very low chance that the command will be recognized after an update anyway.

Actual behaviour

Currently tldr tried to update the cache every time it doesn't recognize a command. It's a bit slow process that involves a network communication. And also it seems it's at least not necessary to do it every time, which is the case when the user tries to see if the command becomes recognized after a cache update, or when the user just check several commands in a row. The latter case happens a lot to a user without auto-completion installed.

Log, debug output

$ tldr sss
✔ Page not found. Updating cache
✔ Creating index
Page not found.
Feel free to send a pull request to: https://github.com/tldr-pages/tldr
$ tldr sss
✔ Page not found. Updating cache
✔ Creating index
Page not found.
Feel free to send a pull request to: https://github.com/tldr-pages/tldr

Environment

  • OS: Ubuntu 16.04.3 LTS
  • NodeJS version: v10.6.0
@sbrl
Copy link
Member

sbrl commented Jul 11, 2018

Hey, thanks for the issue! I suspect this behaviour should be configured via a setting (which ought to default to on). @agnivade, thoughts?

@agnivade
Copy link
Member

Agree. We already have a cache.lastUpdated() function. So we just need a new config value which specifies the duration. And then when a page is not found, we just check whether now() - cache.lastUpdated() is greater than the duration, if yes, then update the cache.

I am available for reviews if anyone wants to send a PR.

@agnivade agnivade changed the title Behavior when tldr doesn't recognized a command specify a config param to control updating cache when a page is not found Jul 12, 2018
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

3 participants