Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public class UpdateViewCountService {
@Transactional
@Async
public void updateViewCount(String key) {
log.info("updateViewCount Processing key: {} in thread: {}", key, Thread.currentThread().getName());
Long postId = redisUtils.getPostIdFromPostViewCountRedisKey(key);
Post post = postRepository.getById(postId);
postRepository.increaseViewCount(postId, redisService.getAndDelete(key));
log.info("updateViewCount Updated post id: {} with view count from key: {}", postId, key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.example.solidconnection.util.RedisUtils;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
Expand All @@ -18,7 +17,6 @@
@Component
@EnableScheduling
@EnableAsync
@Slf4j
public class UpdateViewCountScheduler {

private final RedisUtils redisUtils;
Expand All @@ -29,7 +27,6 @@ public class UpdateViewCountScheduler {
@Scheduled(fixedDelayString = "${view.count.scheduling.delay}")
public void updateViewCount() {

log.info("updateViewCount thread: {}", Thread.currentThread().getName());
List<String> itemViewCountKeys = redisUtils.getKeysOrderByExpiration(VIEW_COUNT_KEY_PATTERN.getValue());

itemViewCountKeys.forEach(key -> asyncExecutor.submit(() -> {
Expand Down
Loading