-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from f-lab-edu/feature/76
[#76] 개인 맞춤 피드 제공
- Loading branch information
Showing
23 changed files
with
528 additions
and
54 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Stoury-batch/src/test/groovy/com/learning/RedisTemplateTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.learning | ||
|
||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory | ||
import org.springframework.data.redis.core.Cursor | ||
import org.springframework.data.redis.core.ScanOptions | ||
import org.springframework.data.redis.core.StringRedisTemplate | ||
import spock.lang.Specification | ||
|
||
class RedisTemplateTest extends Specification { | ||
def connectionFactory = new LettuceConnectionFactory("localhost", 8379) | ||
def redisTemplate = new StringRedisTemplate(connectionFactory) | ||
def testKey = "TestKey" | ||
Cursor<byte[]> cursor | ||
|
||
def setup(){ | ||
connectionFactory.start() | ||
redisTemplate.delete(testKey) | ||
} | ||
|
||
def cleanup() { | ||
if (cursor != null && !cursor.isClosed()) { | ||
cursor.close() | ||
} | ||
} | ||
|
||
def "opsForSet에 addAll() 가능한지"(){ | ||
given: | ||
def opsForSet = redisTemplate.opsForSet() | ||
def list = [1L, 2L, 3L, 4L] | ||
String[] stringArr = list.stream().map(String::valueOf).toArray() | ||
when: | ||
opsForSet.add(testKey, stringArr) | ||
then: | ||
opsForSet.members(testKey).size() == 4 | ||
} | ||
def "SCAN 했는데 왜 key가 반환이 안되지"() { | ||
given: | ||
redisTemplate.opsForSet().add("FrequentTags:3333", "val1") | ||
redisTemplate.opsForSet().add("FrequentTags:2222", "val1") | ||
redisTemplate.opsForSet().add("FrequentTags:1113", "val1") | ||
def scanOption = ScanOptions.scanOptions().match("FrequentTags:*").count(1).build() | ||
cursor = redisTemplate.getConnectionFactory().getConnection().keyCommands().scan(scanOption) | ||
expect: | ||
cursor.hasNext() | ||
cursor.hasNext() | ||
cursor.hasNext() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.stoury.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "CLICK_LOG") | ||
public class ClickLog { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(name = "MEMBER_ID") | ||
private Long memberId; | ||
@Column(name = "FEED_ID") | ||
private Long feedId; | ||
@Column(name = "CREATED_AT") | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
public ClickLog(Long memberId, Long feedId, LocalDateTime createdAt) { | ||
this.memberId = memberId; | ||
this.feedId = feedId; | ||
this.createdAt = createdAt; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/stoury/repository/ClickLogRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.stoury.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.stoury.domain.ClickLog; | ||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class ClickLogRepository { | ||
private final EntityManager entityManager; | ||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Transactional | ||
public ClickLog save(ClickLog feedClick) { | ||
entityManager.persist(feedClick); | ||
return feedClick; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.