Skip to content

Commit

Permalink
fix: image caching error
Browse files Browse the repository at this point in the history
- 이미지 캐싱 중 조회 count가 두배로 증가하는 버그 수정
  • Loading branch information
seokwns committed Jan 23, 2024
1 parent a7a49a7 commit 0f42987
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.see.realview.image.repository.impl;

import com.querydsl.core.types.CollectionExpression;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.core.types.dsl.StringTemplate;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.see.realview.image.entity.Image;
import com.see.realview.image.entity.QImage;
Expand All @@ -13,6 +18,7 @@
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.stream.Collectors;

@Repository
public class ImageRepositoryImpl implements ImageRepository {
Expand Down Expand Up @@ -41,6 +47,10 @@ public ImageRepositoryImpl(@Autowired EntityManager entityManager,

@Override
public List<Image> findAllByUrlIn(List<String> urls) {
if (urls.isEmpty()) {
return List.of();
}

return jpaQueryFactory
.selectFrom(TABLE)
.where(TABLE.link.in(urls))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void rebase() {
imageRepository
.findCachingImages()
.forEach(image -> {
ImageData imageData = new ImageData(image.getAdvertisement(), image.getCount());
ImageData imageData = new ImageData(image.getAdvertisement(), 0L);
CachedImage cachedImage = new CachedImage(image.getLink(), imageData);

imageRedisRepository.save(cachedImage);
Expand Down

0 comments on commit 0f42987

Please sign in to comment.