Cpp_Redis 라이브러리 추가

Yongs12 ㅣ 2024. 11. 23. 17:38

 

github주소

https://github.com/cpp-redis/cpp_redis

 

GitHub - cpp-redis/cpp_redis: C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform - cpp-redis/cpp_redis

github.com

 

해당 프로젝트를 다운 받은 후 해당 폴더에 있는 프로젝트를 빌드 해준다.

 

출력된 라이브러리 파일을 쓰려고 하는 프로젝트에서 사용하면 된다.

 

그러나 현재 기준 cpp_redis에서 쓰는 라이브러리인 tacopie가 비어있기 때문에 이것도 빌드해줘야 한다.

 

깃허브 주소에서 해당 폴더를 들어가서 다운로드 받는다.

 

 

해당 압축을 해제 후 똑같이 msvc15의 프로젝트를 빌드해서 cpp_redis와 같이 써야한다.

 

마지막으로 라이브러리를 쓰기 위해선 Header파일을 넣어주면 된다.

 

 

cpp_redis 간단 사용 예시

	cpp_redis::client client;

	client.connect("127.0.0.1", 6379);
	
	client.ping([](cpp_redis::reply& reply) 
		{
			std::cout << "Reply: " << reply.as_string() << std::endl;  
		});

	client.sync_commit();

 

핑퐁을 통해 연결 상태를 확인할 수 있다.