{"id":19778737,"url":"https://github.com/acl-dev/redis","last_synced_at":"2026-02-09T15:35:36.416Z","repository":{"id":149129301,"uuid":"542868118","full_name":"acl-dev/redis","owner":"acl-dev","description":"The powerful redis client in Acl project","archived":false,"fork":false,"pushed_at":"2022-09-29T02:05:40.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-01T01:39:45.606Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acl-dev.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}},"created_at":"2022-09-29T01:43:06.000Z","updated_at":"2022-09-29T01:43:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"770f8c03-c04d-4a02-8c8a-09153dcba195","html_url":"https://github.com/acl-dev/redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/acl-dev/redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acl-dev","download_url":"https://codeload.github.com/acl-dev/redis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acl-dev%2Fredis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29271030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"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":[],"created_at":"2024-11-12T05:31:07.909Z","updated_at":"2026-02-09T15:35:36.400Z","avatar_url":"https://github.com/acl-dev.png","language":null,"readme":"# Acl redis - One C++ redis client library in Acl\r\n\r\n## 0. Introduction\r\nThe redis module in Acl project (https://github.com/acl-dev/acl) is a powerful redis client library with higth performance, rich interface and easy to use. There are more than 13 C++ classes and over 150 commands in Acl redis, including STRING, HASH, LIST, SET, ZSET, HyperLogLog, PUBSUB, STREAM, TRANSACTION, SCRIPT, CONNECTION, SERVER, etc. User using Acl redis doesn't need care about network comminucation, redis protocol, hash slots caching, etc., just like using C++ STL standard interface. You can see the source codes in https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/src/redis, heads in https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/include/acl_cpp/redis, and many examples in https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/samples/redis can be found.\r\n\r\n\u003chr\u003e\r\n\r\n* [0. Introduction](#0-introduction)\r\n* [1. Building Acl redis](#1-building-acl-redis)\r\n    * [1.1. Compiling on UNIX/LINUX](#11-compiling-on-unixlinux)\r\n    * [1.2. Compiling on Windows](#12-compiling-on-windows)\r\n* [2. Write some examples using Acl redis](#2-write-some-examples-using-acl-redis)\r\n    * [2.1. Simple example for redis STRING and redis KEY](#21-simple-example-for-redis-string-and-redis-key)\r\n    * [2.2. Redis client cluster example for redis3.0+](#22-redis-client-cluster-example-for-redis30)\r\n    * [2.3. Using redis client cluster in multi-threads](#23-using-redis-client-cluster-in-multi-threads)\r\n    * [2.4. Use redis pipeline in multi-threads](#24-use-redis-pipeline-in-multi-threads)\r\n* [3. Add Acl redis to your projects](#3-add-acl-redis-to-your-projects)\r\n    * [3.1. On UNIX/LINUX](#31-on-unixlinux)\r\n    * [3.2. On Windows](#32-on-windows)\r\n* [4. Reference](#4-reference)\r\n* [5. About Acl](#5-about-acl)\r\n\r\n\u003chr\u003e\r\n\r\n## 1. Building Acl redis\r\nAcl redis is a part of lib_acl_cpp, so users only need to build the Acl project.\r\n\r\n### 1.1. Compiling on UNIX/LINUX\r\n- Enter the root directory of the Acl project and type **make**, **libacl_all.a** will be created later, which consists of three libraries: **libacl_cpp.a**, **lib_protocol.a** and **lib_acl.a**;\r\n- Compile redis samples: Enter into lib_acl_cpp/samples/redis and type **make**, all the redis samples(including redis_cluster, redis_connection, redis_hash, redis_hyperloglog, redis_key, redis_lib, redis_manager, redis_pool, redis_pubsub, redis_server, redis_set, redis_string, redis_trans, redis_zset, redis_zset_pool, redis_client_cluster) will be compiled.\r\n\r\n### 1.2. Compiling on Windows\r\nUsers can use `VS2003/VS2008/VS2010/VS2012/VS2015/VS2017/VS1019` to compile all Acl libraries by opening the Acl projects(acl_cpp_vc2003.sln, acl_cpp_vc2008.sln, acl_cpp_vc2010.sln, acl_cpp_vc2012.sln, acl_cpp_vc2015.sln, acl_cpp_vc2017.sln, acl_cpp_vc2019.sln) with the corresponding VS tools. Due to the dependency in Acl, lib_acl should be compiled first, then lib_protocol, and finally lib_acl_cpp.\r\n\r\n## 2. Write some examples using Acl redis\r\n### 2.1. Simple example for redis STRING and redis KEY:\r\n```c++\r\n#include \u003cstdlib.h\u003e\r\n#include \u003cstdio.h\u003e\r\n#include \"acl_cpp/lib_acl.hpp\"\r\n\r\nstatic void test_redis_string(acl::redis\u0026 cmd, const char* key) {\r\n\tacl::string val(\"test_value\");\r\n\r\n\t// call redis-server: SET key value\r\n\tif (!cmd.set(key, val.c_str())) {\r\n\t\tprintf(\"redis set error\\r\\n\");\r\n\t\treturn;\r\n\t}\r\n\r\n\t// clear the string buf space\r\n\tval.clear();\r\n\r\n\t// reset the redis command object for reusing it\r\n\tcmd.clear();\r\n\r\n\t// call redis-server: GET key\r\n\tif (!cmd.get(key, val)) {\r\n\t\tprintf(\"get key error\\r\\n\");\r\n\t}\r\n}\r\n\r\nstatic void test_redis_key(acl::redis\u0026 cmd, const char* key) {\r\n\tif (cmd.exists(key)) {\r\n\t\tprintf(\"key exists\\r\\n\");\r\n\t} else {\r\n\t\tprintf(\"key not exists\\r\\n\");\r\n\t}\r\n}\r\n\r\nint main(void) {\r\n\t// init socket module for windows\r\n\tacl::acl_cpp_init();\r\n\r\n\tconst char* redis_addr = \"127.0.0.1:6379\";\r\n\tint conn_timeout = 10, rw_timeout = 10;\r\n\r\n\t// the redis client connection\r\n\tacl::redis_client conn(redis_addr, conn_timeout, rw_timeout);\r\n\r\n\tconst char* key = \"test_key\";\r\n\r\n\t// Bind redis_string command with redis connection.\r\n\tacl::redis cmd(\u0026conn);\r\n\ttest_redis_string(cmd, key);\r\n\r\n\tcmd.clear();  // Clear the temp memory.\r\n\r\n\t// Test redis KEY command with the same redis connection.\r\n\ttest_redis_key(cmd, key);\r\n\r\n\treturn 0;\r\n}\r\n```\r\n### 2.2. Redis client cluster example for redis3.0+\r\n```c++\r\n#include \u003cstdlib.h\u003e\r\n#include \u003cstdio.h\u003e\r\n#include \"acl_cpp/lib_acl.hpp\"\r\n\r\nint main(void) {\r\n\t// Init socket module for windows\r\n\tacl::acl_cpp_init();\r\n\r\n\tconst char* redis_addr = \"127.0.0.1:6379\";\r\n\tint conn_timeout = 10, rw_timeout = 10, max_conns = 100;\r\n\r\n\t// Declare redis connection cluster ojbect.\r\n\tacl::redis_client_cluster cluster;\r\n\tcluster.set(redis_addr, max_conns, conn_timeout, rw_timeout);\r\n\r\n\t// Redis operation command.\r\n\tacl::redis cmd;\r\n\r\n\t// Bind redis command with redis connection cluster.\r\n\tcmd.set_cluster(\u0026cluster);\r\n\r\n\tconst char* key = \"test_key\";\r\n\r\n\t// Call redis server\r\n\ttest_redis_string(cmd, key);\r\n\tcmd.clear();\r\n\ttest_redis_key(cmd, key);\r\n\r\n\treturn 0;\r\n}\r\n```\r\nThe redis cluster module of Acl supports caching the redis hash slots on client to improve performance, and can dynamically change local hash slots at runtime.\r\n\r\n### 2.3. Using redis client cluster in multi-threads\r\n```c++\r\n#include \u003cstdlib.h\u003e\r\n#include \u003cstdio.h\u003e\r\n#include \u003cpthread.h\u003e\r\n#include \"acl_cpp/lib_acl.hpp\"\r\n\r\nstatic int __max_conns = 100;\r\n\r\nstatic void* thread_main(void* arg) {\r\n\tacl::redis_client_cluster* cluster = (acl::redis_client_cluster*) arg;\r\n\r\n\tacl::redis cmd;\r\n\tcmd.set_cluster(cluster);\r\n\r\n\tconst char* key = \"test_key\";\r\n\r\n\tfor (int i = 0; i \u003c 100000; i++) {\r\n\t\ttest_redis_string(cmd, key);\r\n\t\ttest_redis_key(cmd, key);\r\n\t\tcmd.clear(); // Clear temporary meory to avoid meory overflow.\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nint main(void) {\r\n\t// init socket module for windows\r\n\tacl::acl_cpp_init();\r\n\r\n\tconst char* redis_addr = \"127.0.0.1:6379\";\r\n\tint conn_timeout = 10, rw_timeout = 10;\r\n\r\n\t// declare redis cluster ojbect\r\n\tacl::redis_client_cluster cluster;\r\n\tcluster.set(redis_addr, __max_conns, conn_timeout, rw_timeout);\r\n\r\n\tpthread_attr_t attr;\r\n\tpthread_attr_init(\u0026attr);\r\n\t\r\n\t// create first thread\r\n\tpthread_t id1;\r\n\tpthread_create(\u0026id1, \u0026attr, thread_main, \u0026cluster);\r\n\r\n\t// create second thread\r\n\tpthread_t id2;\r\n\tpthread_create(\u0026id2, \u0026attr, thread_main, \u0026cluster);\r\n\r\n\tpthread_join(id1, NULL);\r\n\tpthread_join(id2, NULL);\r\n\r\n\treturn 0;\r\n}\r\n```\r\n\r\n### 2.4. Use redis pipeline in multi-threads\r\n```c++\r\n#include \u003cstdlib.h\u003e\r\n#include \u003cstdio.h\u003e\r\n#include \u003cpthread.h\u003e\r\n#include \"acl_cpp/lib_acl.hpp\"\r\n\r\nstatic void* thread_main(void* arg) {\r\n\tacl::redis_client_pipeline* pipeline = (acl::redis_client_pipeline*) arg;\r\n\r\n\tacl::redis cmd;\r\n\tcmd.set_pipeline(pipeline);\r\n\r\n\tacl::string key;\r\n\r\n\tfor (int i = 0; i \u003c 100000; i++) {\r\n\t\tkey.format(\"test-key-%d\", i);\r\n\t\ttest_redis_string(cmd, key);\r\n\t\ttest_redis_key(cmd, key);\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nint main(void) {\r\n\t// Init socket module for windows\r\n\tacl::acl_cpp_init();\r\n\r\n\tconst char* redis_addr = \"127.0.0.1:6379\";\r\n\r\n\t// Declare redis pipeline ojbect\r\n\tacl::redis_client_pipeline pipeline(redis_addr);\r\n\r\n\t// Start the pipeline thread backend.\r\n\tpipeline.start_thread();\r\n\r\n\tpthread_attr_t attr;\r\n\tpthread_attr_init(\u0026attr);\r\n\t\r\n\tstd::vector\u003cpthread_t\u003e threads;\r\n\t// start some threads to execute redis operations\r\n\tfor (size_t i = 0; i \u003c 100; i++) {\r\n\t\tpthread_t id;\r\n\t\tint ret = pthread_create(\u0026id, \u0026attr, thread_main, \u0026pipeline);\r\n\t\tif (ret == 0) {\r\n\t\t\tthreads.push_back(id);\r\n\t\t}\r\n\t}\r\n\r\n\t// wait for all threads to exit\r\n\tfor (std::vector\u003cpthread_t\u003e::iterator it = threads.begin();\r\n\t\tit != threads.end(); ++it) {\r\n\r\n\t\tpthread_join(*it, NULL);\r\n\t}\r\n\r\n\t// stop the pipeline thread\r\n\tpipeline.stop_thread();\r\n\treturn 0;\r\n}\r\n```\r\n\r\n## 3. Add acl redis to your projects\r\nBefore using Acl redis, you should compile the three basic libraries. Enter the *lib_acl*, *lib_protocol*, *lib_acl_cpp*, and build the `lib_acl.a`, `lib_protocol.a` and `libacl_cpp.a`.\r\n```compile\r\n$cd lib_acl; make\r\n$cd lib_protocol; make\r\n$cd lib_acl_cpp; make\r\n```\r\n\r\n### 3.1. On UNIX/LINUX\r\nYou should add the following compilation options in your Makefile:\r\n- **Compling options:** `-I` specify the lib_acl.hpp's parent path, for exmaple: `-I./lib_acl_cpp/include`;\r\n- **Linking options:** Link with -L{path_to_acl_cpp} -lacl_cpp -L{path_to_protocol} -lprotocol -L{path_to_acl) -lacl ;\r\n- **Reference:** lib_acl_cpp/samples/Makefile.in, lib_acl_cpp/samples/redis/redis/Makefile.\r\n\r\nOne Makefile as below:\r\n```Makefile\r\nACL_PATH=./acl\r\nCFLAGS = -c -g -W -O3 -Wall -Werror -Wshadow \\\r\n\t-Wno-long-long -Wpointer-arith -D_REENTRANT \\\r\n\t-D_POSIX_PTHREAD_SEMANTICS \\\r\n\t-I $(ACL_PATH)/lib_acl_cpp/include\r\nLDFLAGS = -L$(ACL_PATH)/lib_acl_cpp/lib -lacl_cpp \\\r\n\t-L$(ACL_PATH)/lib_protocol/lib -lprotocol \\\r\n\t-L$(ACL_PATH)/lib_acl/lib -lacl \\\r\n\t-lpthread\r\ntest: main.o\r\n\tg++ -o main.o $(LDFLAGS)\r\nmain.o: main.cpp\r\n\tg++ $(CFLAGS) main.cpp -o main.o\r\n```\r\n### 3.2. On Windows\r\nOpen the VS projects, such as acl_cpp_vc2003.sln, acl_cpp_vc2008.sln, acl_cpp_vc2010.sln, acl_cpp_vc2012.sln, acl_cpp_vc2013.sln, acl_cpp_vc2015.sln, acl_cpp_vc2017.sln, or acl_cpp_vc2019.sln to  look at the redis samples project option setting.\r\n\r\n## 4. Reference\r\n- Acl redis headers: [Redis include files](https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/include/acl_cpp/redis)\r\n- Acl redis source: [Redis source files](https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/src/redis)\r\n- More examples: [Redis samples](https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/samples/redis)\r\n## 5. About Acl\r\n- See [About Acl](https://github.com/acl-dev/acl)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facl-dev%2Fredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facl-dev%2Fredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facl-dev%2Fredis/lists"}