Redis 특강

brave_chicken·2024년 7월 2일

잇(IT)생 챌린지

목록 보기
82/90

redis 다운로드

redis.io

1. String

단일값저장

set key
get key

2. SortedSet

ZSet이라고도 한다.
저장된 데이터를 유니크하게 관리하기 위해서 사용

1) zadd

zadd key score member

  • key : sortedset의 이름
  • score : 각 요소에 할당된 점수
  • member : 각 요소의 이름(값)

2) zrange

정렬된 원소에서 내가 출력하고 싶은 start번호 end번호
첫번째요소가 0
마지막요소가 -1

3) zrem

삭제

4) zrangebyscore

zrangebyscore key min max

zrangebyscore key (min(max

=> min초과 max미만

5) zrevrangebyscore

zrevrangebyscore myset1 +inf (20000 withscores

20000보다 높은 score의 member들을 조회

6) zscore

zscore key member

지정한 member에 대한 score를 조회

7) zrank

zrank key member

해당 member의 순위 조회

실습

key => myboard

1. 게시글과 조회수를 sortedset에 저장

5개를 임의로 저장
조회수와 게시글번호

2. 전체글과 조회수를 모두 조회

3. 조회수가 가장 많은 글 조회

4. 1위의 게시글 조회







hash


실습

BoardDTO의 모든 값을 hashes로 저장하기
myboardhash

redis intelliJ프로젝트 만들기









본 포스팅은 멀티캠퍼스의 멀티잇 백엔드 개발(Java)의 교육을 수강하고 작성되었습니다.

0개의 댓글