{"id":34829768,"url":"https://github.com/daggilli/rediscpp","last_synced_at":"2026-04-26T07:34:06.298Z","repository":{"id":320469332,"uuid":"1071931854","full_name":"daggilli/rediscpp","owner":"daggilli","description":"A lightweight header-only C++ interface to Redis","archived":false,"fork":false,"pushed_at":"2026-02-18T19:13:22.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-26T07:34:04.601Z","etag":null,"topics":["cpp","cpp26","lightweight","modern-cpp","redis","wrapper"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daggilli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-08T02:54:40.000Z","updated_at":"2026-02-18T19:12:28.000Z","dependencies_parsed_at":"2025-10-27T13:01:35.150Z","dependency_job_id":"f65991da-ec28-41ff-b70c-90505d98b274","html_url":"https://github.com/daggilli/rediscpp","commit_stats":null,"previous_names":["daggilli/rediscpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daggilli/rediscpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggilli%2Frediscpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggilli%2Frediscpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggilli%2Frediscpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggilli%2Frediscpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daggilli","download_url":"https://codeload.github.com/daggilli/rediscpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggilli%2Frediscpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32289926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T06:26:00.361Z","status":"ssl_error","status_checked_at":"2026-04-26T06:25:58.791Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp26","lightweight","modern-cpp","redis","wrapper"],"created_at":"2025-12-25T15:33:12.965Z","updated_at":"2026-04-26T07:34:06.293Z","avatar_url":"https://github.com/daggilli.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REDISCPP\n\n## A simple, modern C++ wrapper for Redis\n\n#### RedisCpp is a header-only interface to the Redis in-memory key/value store.\n\nThe goal of this project is to present a C++ interface to Redis that is as simple as possible to use. It uses modern C++ features to perform a number of checks at compile time, making correct usage easier. Binaries built using a release-grade configuration are typically only a few hundred kilobytes, making them more suitable for small computers with restricted memory such as the Raspberry Pi.\n\n### Prerequisites\n\nA modern C++ compiler is required. The minimum standard that will compile cleanly is C++23. C++26 is preferred. In practice this means GCC 15 or later, or clang 20 or later. These are heavyweight compilers, so for use on small computers cross-compilation may be the best strategy.\n\nRedisCpp is built on top of [hiredis](https://github.com/redis/hiredis). The hiredis library and development headers must ne installed.\n\nParsing the configuration file uses [TOML++](https://github.com/marzer/tomlplusplus) and this must be installed along with tis header files.\n\nIf cross-compiling, the target machine will need the hiredis and TOML++ libraries.\n\nBuilding the documentation requires [Doxygen](https://doxygen.nl/index.html).\n\n### Installation\n\nNavigate to the project root. The included `CMAKE` script will prepare the necessary makefiles. Then `INSTALL` will copy the required files to `/usr/local/include`. Package configuration files for `cmake` will be written to `/usr/local/share/RedisCpp/cmake` so the libary can be located with `find_package` in your project's `CMakeLists.txt` file. To build the examples, use the `DBUILD` and `RBUILD` scripts to create the Debug and Release versions respectively. The documentation can be generated with the `DOCS` script (assuming you have Doxygen installed).\n\n### Usage\n\nThe library is header-only. By default it is installed in `/usr/local/include`. Typically, simply `#include \u003crediscpp.hpp\u003e`. This includes two subheaders, `rediscppimpl.hpp` and `rediscppconfig.hpp` which can be included individually in your project if you do not need the functionality of one of them.\n\n### Example code\n\nAlmnost all of the functionality of the library is covered in a set of example programs which are found in `src/examples`. Thet can be built with the `RBUILD` and `DBUILD` scripts for Release and Debug versions respectively. The Debug versions are built with Address Sanitizer enabled, which helps to catch a wide range of memory errors such as use-after-free or dereferending `nullptr`. Executables will be created in `build/examples/[Release|Debug]`. The core class through which communication with the Redis server is mediated is `RedisCpp::Client`. Configuration is handled by the `RedisCpp:Config` class.\n\nMany of the available functions take a variable number of arguments, which in general must be string-like. This means C-style strings, `std::string` and `std::string)view`. In most cases, rvalue `std::string` paraneters are _not_ allowed. In other words code that looks like:\n\n```cpp\n  client.func(std::string(\"abc\"), ...);\n```\n\nwill fail to compile. The reason for this is that internally the code uses `std::string_view` for string-like objects, and allocating a temporary like this is dangerous as it will be immediately deallocated, leaving the internal `string_view` pointing to invalid memory. This constraint is enforced at compile time, making it safer to use the library.\n\nOn the other hand, code such as:\n\n```cpp\n  client.func(std::string_view(\"abc\"), ...);\n```\n\nis perfectly acceptable (albeit fairly useless) as `std::string_view` does not take ownership of the `\"abc\"` string literal.\n\nMost of the public member functions of the the `RedisCpp::Client` class are ref-qualified `\u0026`. This is to prevent the use of temporaries. In other words, code such as the following will fail to compile:\n\n```cpp\nRedisCpp::Client(RedisCpp::Config{\"localhost\", 6379}).get(\"foo\");\n```\n\nThis is intentional.\n\n### Client configuration\n\nAn instance of `RedisCpp::Client` requires a configuration of type `RedisCpp::Config`. This must at least specify the server URL and port number.\n\nA constructor for `RedisCpp::Config` exists to specify parameters individually, which takes mandatory values for the server host and port. Additional parameters control the database number to use (0-15), whether to use basic AUTH to connect, the username and password if so, and whether to upgrade the protocol to the RESP3 standard.\n\nThe `RedisCpp::Config` class has the following shape:\n\n```cpp\nstd::string hostname;\nint port;\nstd::optional\u003cint\u003e db;\nbool useAuth;\nstd::optional\u003cstd::string\u003e username;\nstd::optional\u003cstd::string\u003e password;\nstd::optional\u003cbool\u003e useResp3;\n\n```\n\nA client configuration can be created by providing the path to a TOML file containing a suitable object specification. The TOML object in this files should have the following shape:\n\n```toml\n[redis]\nhostname = \u003cstring\u003e\nport = \u003cint\u003e\ndb = \u003cint 0-15, optional, default 0\u003e\nuseauth = \u003cboolen, optional, default false\u003e\nusername = \u003cstring, optional, default null\u003e\npassword = \u003cstring, optional, default null\u003e\nuseresp3 = \u003cboolean, optional, default true\u003e\n```\n\nThus a possible config file could looke like:\n\n```toml\n[redis]\nhostname = \"redis-server\"\nport = 26379\ndb = 12\nuseauth = true\nusername = \"redisuser\"\npassword = \"jWhbkZmt\"\n```\n\nNote that key names in this object are all **lowercase**.\n\nA typical preamble for a program using this library might be as follows:\n\n```cpp\n#include \u003crediscpp.hpp\u003e\n\nint main() {\n  RedisCpp::Config config(\"path/to/config\");\n  RedisCpp::Client client(config);\n\n  ... // do something\n\n  return 0;\n}\n```\n\nNote that the connection to Redis is closed when the `Client` object goes out of scope. If a persistent connection is required it must be kept alive in some fashion (this is left to the user).\n\n---\n\n\u003csup\u003e\u003csub\u003e\nCopyright (c) 2025–2026 David Gillies\u003cbr\u003e\nSPDX-License-Identifier: BSD-3-Clause\n\u003csub\u003e\u003csup\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaggilli%2Frediscpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaggilli%2Frediscpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaggilli%2Frediscpp/lists"}