Skip to content

基于注解的缓存装饰器#126

Open
tq13111 wants to merge 1 commit intohcsp:masterfrom
tq13111:master
Open

基于注解的缓存装饰器#126
tq13111 wants to merge 1 commit intohcsp:masterfrom
tq13111:master

Conversation

@tq13111
Copy link

@tq13111 tq13111 commented Feb 23, 2022

  • 这个PR解答了当前仓库中的题目(机器人会自动判题并合并当前PR)
  • 这个PR修复了当前仓库中的一些代码缺陷(机器人不会判题,而是由管理员来处理当前PR)

@hcsp-bot
Copy link
Contributor

🎉 感谢提交Pull Request!请稍等片刻,我们已经将其提交到CI进行检查,一旦有结果会立即通知您!


import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.bind.annotation.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

不应使用 '.*' 形式的导入 - net.bytebuddy.implementation.bind.annotation.* 。

CacheKey cacheKey = new CacheKey(thisObject, method.getName(), arguments);
CacheValue getValueFromCache = cache.get(cacheKey);
if (getValueFromCache != null) {
if(isExpiredForCache(getValueFromCache,method)){
Copy link
Contributor

Choose a reason for hiding this comment

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

'if' 后应有空格。
',' 后应有空格。
'{' 前应有空格。

}
private static boolean isExpiredForCache(CacheValue cacheValue, Method method) {
int cacheSeconds = method.getAnnotation(Cache.class).cacheSeconds();
return System.currentTimeMillis() - cacheValue.time >= cacheSeconds*1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

'*' 后应有空格。
'*' 前应有空格。

if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CacheKey cacheKey = (CacheKey) o;
return Objects.equals(thisObject, cacheKey.thisObject) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

'&&' 应另起一行。

if (o == null || getClass() != o.getClass()) return false;
CacheKey cacheKey = (CacheKey) o;
return Objects.equals(thisObject, cacheKey.thisObject) &&
Objects.equals(methodName, cacheKey.methodName) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

'&&' 应另起一行。

* @return 查询到的数据列表
*/
@Cache
@Cache(cacheSeconds=2)
Copy link
Contributor

Choose a reason for hiding this comment

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

'=' 后应有空格。
'=' 前应有空格。

@hcsp-bot
Copy link
Contributor

你的提交 d558c30 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

1 similar comment
@hcsp-bot
Copy link
Contributor

你的提交 d558c30 ,似乎失败了:Your tests failed on CircleCI

😅 请不要气馁,仔细分析原因,再接再厉!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants