Redis/redis
[Redis] sets
오늘도개발
2024. 5. 9. 13:24
1. Redis Sets 란?
- 순서가 지정되지 않은 컬렉션
- 일반적인 집합 연산 수행
2. Redis Sets 사용 방법
- SADD, SREM 로 데이터를 입력 및 삭제
> SADD trips:recommend:1 tripId:1
(integer) 1
> SADD trips:recommend:1 tripId:2
(integer) 0
> SADD trips:recommend:2 tripId:1 tripId:3
(integer) 2
- SISMEMBER 로 해당 키값이 존재하는지 확인
> SISMEMBER trips:recommend:1 tripId:1
(integer) 1
> SISMEMBER trips:recommend:1 tripId:2
(integer) 0
- SINTER로 교집합 확인
> SINTER trips:recommend:1 trips:recommend:2
1) "tripId:1"
- SCARD로 데이터 갯수 확인
> SCARD trips:recommends:2
(integer) 2