hiredis_connection
Hiredis Connection
 
Redis Developer Course
 | 
 
Redis Technical Support
 | 
 
Redis Enterprise Server
 | 
|---|
Connection
Sample program
- 연결과 간단한 명령 실행     (vi :set paste)
Redis version 7부터는 requirepass(password)가 거의 필수이므로 AUTH 명령을 추가했다. - 정상인 경우 실행 결과
 - 레디스 서버가 다운되었을 때
 - Reply free -> freeReplyObject(reply);
 - Context free -> redisFree(c);
 
redisReply 구조체 RESP3
- redisReply struct
 - type: RESP2, 3 공통
 - REDIS_REPLY_ERROR: 에러가 발생했을 경우, 에러 내용은 redisReply->str에 있다.
 - REDIS_REPLY_NIL: 값이 없을 경우, 예를 들어 GET XXX 했는데 키 XXX가 없을 경우.
 - REDIS_REPLY_INTEGER: 리턴 값이 integer인 경우, 값은 redisReply->integer에 있다.
 - REDIS_REPLY_ARRAY: 배열(array) 리턴인 경우, 예를 들어 lrange key 0 -1의 결과일 때.
redisReply->element가 다시 redisReply를 가리킨다. 즉, 값은 redisReply->element[0]->str
redisReply->elements에 배열 개수가 있다. - REDIS_REPLY_STRING: 리턴 값이 bulk(string)일 때, 값은 redisReply->str에 있다.
 - REDIS_REPLY_STATUS: 일반(정상)적인 경우, 값은 redisReply->str에 있다.
 - type: RESP3 추가
 - REDIS_REPLY_DOUBLE: double-precision floating point number. 실수 표시, 주로 zset score에 사용한다.
 - REDIS_REPLY_BOOL: boolean true/false
 - REDIS_REPLY_MAP: 값이 쌍으로 되어 있는 리스트(array), 주로 hash에서 사용한다.
 - REDIS_REPLY_SET: 값이 중복되지 않는 리스트(array), 주로 set에서 사용한다.
 - REDIS_REPLY_ATTR: 메타데이터(meta-data)로 사용. 구조는 map과 같다.
 - REDIS_REPLY_BIGNUM: 큰 정수를 표시할 때 사용한다. 예) 3492890328409238509324850943850943825024385
 - REDIS_REPLY_VERB: Text/String을 그대로 출력할 때 사용한다. 예) info
 - integer: 결과가 숫자일 때
 - len: str의 길이
 - str: 결과 값 또는 에러 메시지
 - elements: 결과가 배열일 때 배열 크기
 - element: 결과가 배열일 때 다시 redisReply를 가리킨다.
 - RESP 자세한 설명은 여기를 보세요.
 
redisReply 구조체 RESP2
- redisReply struct
 - type
 - REDIS_REPLY_ERROR: 에러가 발생했을 경우, 에러 내용은 redisReply->str에 있다.
 - REDIS_REPLY_NIL: 값이 없을 경우, 예를 들어 GET XXX 했는데 키 XXX가 없을 경우.
 - REDIS_REPLY_INTEGER: 리턴 값이 integer인 경우, 값은 redisReply->integer에 있다.
 - REDIS_REPLY_ARRAY: 배열(array) 리턴인 경우, 예를 들어 lrange key 0 -1의 결과일 때.
redisReply->element가 다시 redisReply를 가리킨다. 즉, 값은 redisReply->element[0]->str
redisReply->elements에 배열 개수가 있다. - REDIS_REPLY_STRING: 리턴 값이 bulk(string)일 때, 값은 redisReply->str에 있다.
 - REDIS_REPLY_STATUS: 일반(정상)적인 경우, 값은 redisReply->str에 있다.
 - integer: 결과가 숫자일 때
 - len: str의 길이
 - str: 결과 값 또는 에러 메시지
 - elements: 결과가 배열일 때 배열 크기
 - element: 결과가 배열일 때 다시 redisReply를 가리킨다.
 
| << Hiredis Introduction | Hiredis Connection | Strings >> | 
|---|
	Email
	
	
	답글이 올라오면 이메일로 알려드리겠습니다.
	
 
