Skip to content

Commit

Permalink
fix: hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
doxxx93 committed Feb 22, 2024
1 parent b1a9a61 commit 7aa476a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
@RequiredArgsConstructor
public class PaintLikeService {

private final RedisTemplate<String, String> redisTemplate;
private final RedisTemplate<String, String> redistemplate;

public boolean isLiked(Long userId, Long paintId) {
String key = RedisKeyUtil.constructKey(LIKED_PAINT_PREFIX.getKey(), paintId);
return Optional.ofNullable(redisTemplate.opsForSet().isMember(key, userId.toString())).orElse(false);
return Optional.ofNullable(redistemplate.opsForSet().isMember(key, userId.toString())).orElse(false);
}

public void like(Long userId, Long paintId) {
String key = RedisKeyUtil.constructKey(LIKED_PAINT_PREFIX.getKey(), paintId);
redisTemplate.opsForSet().add(key, userId.toString());
redistemplate.opsForSet().add(key, userId.toString());
}

public void unlike(Long userId, Long paintId) {
String key = RedisKeyUtil.constructKey(LIKED_PAINT_PREFIX.getKey(), paintId);
redisTemplate.opsForSet().remove(key, userId.toString());
redistemplate.opsForSet().remove(key, userId.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ public void incrementViewCount(final Long aLong) {
}

private void changeMetricCount(final Long pid, final String metric, final int delta) {
String key = RedisKeyUtil.constructKey(RedisKeyConstants.METRICS_PREFIX.getKey(), metric, pid);
redistemplate.opsForValue().increment(key, delta);
redistemplate.opsForHash()
.increment(
RedisKeyUtil.constructKey(RedisKeyConstants.METRICS_PREFIX.getKey(), pid),
metric,
delta
);
}

public PaintMetrics getPaintMetrics(final Long pid) {
Expand Down

0 comments on commit 7aa476a

Please sign in to comment.