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

fresh credentials #33

Merged
merged 1 commit into from
Jan 8, 2025
Merged

fresh credentials #33

merged 1 commit into from
Jan 8, 2025

Conversation

TsinghuaDream
Copy link
Contributor

No description provided.

yndu13
yndu13 previously approved these changes Jan 2, 2025
@@ -55,12 +63,8 @@ protected function cache(array $credential)
*/
public function getCredentials()
{
$credentials = $this->getCredentialsInCache();
Copy link
Contributor

Choose a reason for hiding this comment

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

$credentials = $this->getCredentialsInCache();
这里似乎不对。getCredentialsInCache这个不应该换掉,而是加一些逻辑。先判断是否到达了stale_time(过期时间提前15分钟),如果时间到了stale_time,就阻塞刷新,如果没到stale_time就判断是否到了prefetch_time(上次刷新后1小时),如果到了prefetch_time就异步刷新。只不过php不分同步还是异步,所以你全部写成同步。也就是每过1小时刷新一次,每次过期前15分钟刷新一次。既然每次1小时刷一次了,基本也就用不到提前15分钟的这个,15分钟就变成了用来做兜底

Copy link
Contributor

Choose a reason for hiding this comment

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

也就是上面的self::$credentialsCache[$this->key()]缓存的内容,你得缓存每个凭证的prefetch时间和stale时间

Copy link
Contributor

Choose a reason for hiding this comment

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

只不过到了prefetch时间的时候,去远程服务端拿新的凭证,是允许失败的,也就是catch住异常,不阻塞客户主业务,但是记录日志,让用户可以排查。但到了stale_time时,还是失败了,这时候给客户抛出异常

@yndu13 yndu13 merged commit 6054424 into aliyun:master Jan 8, 2025
1 of 10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants