zinter
ZINTER
|  Redis Developer Course |  Redis Technical Support |  Redis Enterprise Server | 
|---|
교집합을 구함
사용법은 zinter 2 src_key1 src_key2 이다.
각 member의 score는 지정하지 않으면 기본으로 더해진다.
| src_key1 = | { (1,A), | (2,B), | (3,C) | } | |
| src_key2 = | { | (4,B), | (5,C) | (6,D) | } | 
| 결과 = | { | (6,B), | (8,C) | } | 
Example
| 명령> | zinter 2 src_key1 src_key2 withscores | 
| 결과> | 1) "B" 2) "6" 3) "C" 4) "8" | 
weights 사용
사용법은 zinter 2 src_key1 src_key2 weights 2 3 이다.
첫 번째 weight 2는 src_key1의 각 score에 곱해지고, 두 번째 weight 3는 src_key2의 각 score에 곱해진다.
| src_key1 = | { (1,A), | (2,B), | (3,C) } | -> | { (2*2,B) | (3*2,C) } | |
| src_key2 = | { | (4,B), | (5,C), | (6,D) } | -> | { (4*3,B) | (5*3,C) } | 
| 결과 | = | { (4+12,B) | (6+15,C) } | ||||
| = | { (16,B) | (21,C) } | 
Example
| 명령> | zinter 2 src_key1 src_key2 weights 2 3 withscores | 
| 결과> | 1) "B" 2) "16" 3) "C" 4) "21" | 
aggregate 사용
사용법은 zinter 2 src_key1 src_key2 aggregate sum|min|max 이다.
sum은 각 score를 합한다. aggregate를 지정하지 않으면 sum 이 default이므로 sum으로 계산된다.
min은 각 member에서 적은 score를 취하고, max는 큰 score를 취한다.
| src_key1 = | { (1,A), | (2,B), | (3,C) } | |
| src_key2 = | { | (4,B), | (5,C), | (6,D) } | 
| aggregate min = | { | (2,B), | (3,C) } | |
| aggregate max = | { | (4,B), | (5,C) } | 
Example
| 명령> | zinter 2 src_key1 src_key2 aggregate min withscores | 
| 결과> | 1) "B" 2) "2" 3) "C" 4) "3" | 
| 명령> | zinter 2 src_key1 src_key2 aggregate max withscores | 
| 결과> | 1) "B" 2) "4" 3) "C" 4) "5" | 
명령문
ZINTER numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX] [WITHSCORES]
- 이 명령은 version 6.2.0 부터 사용할 수 있다.
- 논리적 처리 소요시간은 O(N*K)+O(M*log(M))이다.
| 관련 명령 | ZUNION, | ZDIFF | 
| << ZUNION | ZINTER | ZDIFF >> | 
|---|
	Email
	
	
	답글이 올라오면 이메일로 알려드리겠습니다.
	
 


 
  
			 
			