-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2:将使用率比较低的数据,从自动加载队列中移除; 3:删除缓存时,重置AutoLoadTO中的上次加载时间,让应用尽快去自动加载,而不是等用户下次请求。
- Loading branch information
jiayu.qiu
committed
Mar 9, 2015
1 parent
f29bbbc
commit 0dae4f1
Showing
10 changed files
with
166 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/jarvis/cache/comparator/AutoLoadRequestTimesComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.jarvis.cache.comparator; | ||
|
||
import java.util.Comparator; | ||
|
||
import com.jarvis.cache.to.AutoLoadTO; | ||
|
||
/** | ||
* 根据请求次数,倒序排序,请求次数越多,说明使用频率越高,造成并发的可能越大。 | ||
* @author jiayu.qiu | ||
*/ | ||
public class AutoLoadRequestTimesComparator implements Comparator<AutoLoadTO> { | ||
|
||
@Override | ||
public int compare(AutoLoadTO autoLoadTO1, AutoLoadTO autoLoadTO2) { | ||
if(autoLoadTO1 == null && autoLoadTO2 != null) { | ||
return 1; | ||
} else if(autoLoadTO1 != null && autoLoadTO2 == null) { | ||
return -1; | ||
} else if(autoLoadTO1 == null && autoLoadTO2 == null) { | ||
return 0; | ||
} | ||
if(autoLoadTO1.getRequestTimes() > autoLoadTO2.getRequestTimes()) { | ||
return -1; | ||
} else if(autoLoadTO1.getRequestTimes() < autoLoadTO2.getRequestTimes()) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.