Skip to content

Commit

Permalink
欲引入Redisson框架实现分布式锁
Browse files Browse the repository at this point in the history
  • Loading branch information
x201206030 committed May 25, 2020
1 parent 8f1ed88 commit be7cbe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public void updateDb(Long bookId, Channel channel, Message message) {

log.debug("收到更新数据库消息:" + bookId);
Thread.sleep(1000 * 2);
//TODO 操作共享资源visitCount,集群环境下有线程安全问题,引入Redisson框架实现分布式锁
//目前visitCount不重要,数据可丢失,暂不实现分布式锁
Integer visitCount = (Integer) cacheService.getObject(CacheKey.BOOK_ADD_VISIT_COUNT+bookId);
if(visitCount == null){
visitCount = 0 ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class BookToEsSchedule {
*/
@Scheduled(fixedRate = 1000 * 60)
public void saveToEs() {
//TODO 引入Redisson框架实现分布式锁
//可以重复更新,只是效率可能略有降低,所以暂不实现分布式锁
if (cacheService.get(CacheKey.ES_TRANS_LOCK) == null) {
cacheService.set(CacheKey.ES_TRANS_LOCK, "1", 60 * 20);
try {
Expand Down

0 comments on commit be7cbe2

Please sign in to comment.