mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-27 01:30:51 +00:00
欲引入Redisson框架实现分布式锁
This commit is contained in:
parent
8f1ed88b07
commit
be7cbe2d6f
@ -50,6 +50,8 @@ public class BookVisitAddListener {
|
||||
|
||||
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 ;
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user