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

关于timeout时间设置方面,血的教训 #5

Open
upbit opened this issue Apr 27, 2018 · 1 comment
Open

关于timeout时间设置方面,血的教训 #5

upbit opened this issue Apr 27, 2018 · 1 comment

Comments

@upbit
Copy link
Owner

upbit commented Apr 27, 2018

groupcache会经过如下3个时期:

  1. 从插入后到 expiration (秒)之间:Cache会一直生效;
  2. expirationstalePeriod 之间:先去load()数据,除非达到 staleDeadline 时直接返回Cache,其他优先用load()结果返回;load()后回填Cache;
  3. stalePeriod 之后:强制 load() 数据,无超时;

image

@upbit
Copy link
Owner Author

upbit commented Apr 27, 2018

现阶段,要牢记groupcahe的工作机制,才能设置好上面几个时间:

  1. load()会调用2次,一次getFromPeer(),一次getLocally()
  2. 因为1的原因,staleDeadline 要比上层超时时间的 1/2 还要小(考虑peer间还有1次网络交互);

这几个名字起得并不好,按字面意思,很容易忽略2这个特性。在第一次getFromPeer()失败后直接超时...

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