Skip to content

Instantly share code, notes, and snippets.

@pierswu
Created August 6, 2020 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pierswu/84dda20ce2f3f42b96844a74e6cb81fc to your computer and use it in GitHub Desktop.
Save pierswu/84dda20ce2f3f42b96844a74e6cb81fc to your computer and use it in GitHub Desktop.
public class TokenCache {
private String token;
private LocalDateTime expire;
private String getToken(){
if(token==null
|| LocalDateTime.now().compareTo(expire)>0){
refreshToken();
}
return token;
}
private void refreshToken(){
//获取token的代码
//更新expire,比官方的过期时间稍早一些
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment