Redis high available solution for c++
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
3rd_party
doc
include
project/cmake
sample
src
test
.gitignore
.travis.yml
CMakeLists.txt
LICENSE
README.md
appveyor.yml

README.md

hiredis-happ

Redis HA connector

Environment Linux+OSX (GCC+Clang) Windows
Build Status Build Status Build status
Compiler linux-gcc-4.4
linux-gcc-4.8
linux-gcc-4.9
linux-gcc-7
linux-clang-3.5
osx-apple-clang-6.0
MSVC 14
MSVC 15
Cygwin

Tips

  1. auto reconnect
  2. support redis cluster
  3. [TODO] support redis sential
  4. support raw redis connection

Usage

Linux & Cygwin(hiredis not available in cygwin now)

git clone https://github.com/owt5008137/hiredis-happ.git;
mkdir -p hiredis-happ/build && cd hiredis-happ/build;
# cmake -DDCMAKE_INSTALL_PREFIX=/usr
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake ..;
make;

# for install only, if not installed, all header files are in [BUILDDIR]/include, all libraries files are in [BUILDDIR]/lib
make install

Windows + MSVC

hiredis does not support windows and the Microsoft's branch has no implement redisFormatSdsCommandArgv, so it's unavailable on Windows now.

git clone https://github.com/owt5008137/hiredis-happ.git
mkdir hiredis-happ/build
cd hiredis-happ/build

:: cmake .. -DLIBHIREDIS_ROOT=[hiredis install prefix] -G "Visual Studio 14 2015 Win64"
:: cmake .. -DCMAKE_INSTALL_PREFIX="%ProgramFiles%" -G "Visual Studio 14 2015 Win64"
:: cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "Visual Studio 14 2015 Win64"
cmake .. -G "Visual Studio 14 2015 Win64";

:: using visual studio to build

:: or using msbuild when it's in PATH
msbuild hiredis-happ.sln /p:Configuration=RelWithDebInfo

Custom CMake Options

  • CMAKE_BUILD_TYPE: This cmake option will be default set to Debug.(Please add -DCMAKE_BUILD_TYPE=RelWithDebInfo when used in product environment)
  • LIBHIREDIS_ROOT: Where to find hiredis headers and libraries
  • HIREDIS_VERSION: Hiredis version to download when can not find a available hiredis
  • BUILD_SHARED_LIBS: Default set to OFF
  • ENABLE_BOOST_UNIT_TEST: If using boost.unittest for test framework(default: OFF)
  • PROJECT_ENABLE_SAMPLE: If building samples(default: OFF)
  • PROJECT_ENABLE_UNITTEST: If building unittest(default: OFF)
  • LIBHIREDIS_INCLUDE_DIRS and LIBHIREDIS_LIBRARIES: Where to find hiredis libraries and include directory, these two option should be set both.
  • LIBHIREDIS_USING_SRC: If LIBHIREDIS_INCLUDE_DIRS is the source directory of hiredis

Sample

See sample_cluster_cli for redis cluster practice and sample_raw_cli for raw redis connection.

Both happ_cluster and happ_raw support auto reconnecting and retry when cmd failed.

You can also custom how to print log by using set_log_writer to help you to find any problem.

Document

See doc

Notice

This lib only support Request-Response commands now.(means every request should has only one response).

Unsupport Commands

  • subscribe
  • unsubscribe
  • monitor

Directory list

3rd_party -- script for 3rd party libraries

doc -- document

include -- include files

project -- project configure

src -- source

sample -- samples

test -- unit test

tools -- misc tools