Skip to content

mov-eax/hiredisx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hiredisx

License Build Status codecov C++ Standard CMake

The core intention of the hiredisx library is to create an easier to use threadsafe version of hiredis. Hiredis is very non-prescriptive, making almost no assumptions of your environment. On the otherhand, hiredisx provides some nice easy to use functions for interacting with hiredis that are completely threadsafe and allow for parallel computing... While, also allowing you to interact with redis through the redisx::op::command function.

Click here for full documentation and usage.

Requirements

  1. hiredis

  2. CMake and Make (>=3.7)

Building and Installing

1. Make the build directory

mkdir build
cd build

2. Run cmake and make:

cmake ..
make

3. Install the header libraries

make install

Example usage with CMake

You can pop this into your existing .cmake or CMakeLists.txt:

IF (NOT HIREDISX_INCLUDE_DIRS)
  MESSAGE("-- Setting default HiredisX Include Directory")
  SET(HIREDISX_INCLUDE_DIRS "/usr/local/include/hiredisx")
ENDIF (NOT HIREDISX_INCLUDE_DIRS)

MESSAGE("-- HIREDISX_INCLUDE_DIRS\t" ${HIREDISX_INCLUDE_DIRS})

INCLUDE_DIRECTORIES(${HIREDISX_INCLUDE_DIRS})
LINK_DIRECTORIES(${HIREDISX_INCLUDE_DIRS})

Then interacting with hiredisx is as simple as just adding:

#include "hiredisx.hpp"

Example Usage

Standard Usage:

bool validConnection = hiredisx::test::connect();

if (validConnection) {
    std::string ping = hiredisx::ping(); // PONG if valid.

    bool set = hiredisx::set("foo", "bar"); // True if set

    std::string foo = hiredisx::get("foo"); // "bar" if correct

    bool deleted = hiredisx::del("foo"); // True if deleted

    bool pushed = hiredisx::push("list", "yo", "R"); // True if pushed to list. Note that "R" means Right append, "L" means Left append.

    std::vector<std::string> list = hiredisx::list("list", 0, -1, "L"); // 0 is the start of the list, -1 means the end of the list (you can specify a specific length, 10 being first 10 elements for examples).
}

Modifying Connection Options:

You can modify the connection options by changing the hiredisx::options values. The following are the default values that are modifyable.

hiredisx::options::host = "localhost";
hiredisx::options::port = 6379;
hiredisx::options::timeoutS = 5; // Timeout in seconds
hiredisx::options::timeoutNS = 0; // Timeout in nanoseconds

Additional Resources

  • If you are interested in contributing or want to get in contact. Email me at 📫 hello@chriscates.ca

Releases

No releases published

Packages

No packages published