Skip to content

Instantly share code, notes, and snippets.

@ChrisCates
Last active December 17, 2018 18:45
Show Gist options
  • Select an option

  • Save ChrisCates/1b1ab68cdb16d4406d77226a7917d474 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisCates/1b1ab68cdb16d4406d77226a7917d474 to your computer and use it in GitHub Desktop.
// Add this header after including the hiredis and hiredisx libraries in your build.
#include "hiredisx.hpp"
// Make sure you can connect to the redis instance.
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).
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment