728x90
반응형
SMALL

Redis 3

4_5.리더보드와 Sorted Set 실습

학습내용리더보드 구현 Sorted Set리더보드 최적화Redis Pub/Sub학습정리1. 리더보드 구현 Sorted Set//사용자추가public void addPlayerScore(String player, Double score) { jedis.zadd(LEADERBOARD_KEY, score, player); log.info("Player {} updated wtih score : {}", player, score);}//사용자 조회public void getTopPlayer(Integer topN) { List topPlayers = jedis.zrangeWithScores(LEADERBOARD_KEY, 0, topN - 1); int rank = 1; for (Tuple topPlaye..

TIL 2025.01.17

4_4.Redis와 캐싱 전략, 최적화 실습

학습내용Redis를 활용한 캐싱전략Redis 성능 최적화데이터 일관성 문제 해결학습정리1. Redis를 활용한 캐싱전략@Slf4j@Service@RequiredArgsConstructorpublic class CategoryService { //상수로 redis키 설정 //전역으로 쓰는 상수값은 constants 패키지에서 관리 private static final String CACHE_KEY_CATEGORY_STRUCT = "category_struct"; private static final String CACHE_KEY_PRODUCT_COUNT = "product_count"; private final RedisService redisService; private final Catego..

TIL 2025.01.16

4_3.Redis 데이터 타입 활용

학습내용Redis 주요 데이터 타입Redis 데이터 타입 활용 예제Redis CLI 기본명령어 (간단)학습정리1. Redis 주요 데이터 타입public void redisTypeExample() { log.info("RedisTypeExample"); //===String========== //하나의 키에 하나의 문자열, 숫자 데이터 저장 //숫자를 문자로 저장해도 숫자로 인식을 해서 더하기 빼기가 가능 jedis.set("username", "꿀승"); jedis.set("userAge", "30"); String name = jedis.get("username"); String age = jedis.get("userAge"); log.info("[redisTypeExample] n..

TIL 2025.01.16
728x90
반응형
LIST