{"id":15657703,"url":"https://github.com/somajitdey/redis-client","last_synced_at":"2026-03-11T01:02:25.876Z","repository":{"id":163920169,"uuid":"372180469","full_name":"SomajitDey/redis-client","owner":"SomajitDey","description":"Bash scripting library +  CLI + Connection-pool","archived":false,"fork":false,"pushed_at":"2025-03-18T07:56:36.000Z","size":64,"stargazers_count":24,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T16:04:44.266Z","etag":null,"topics":["bash","connection-pool","no-sql","redis","redis-client","resp-parser"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/SomajitDey.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}},"created_at":"2021-05-30T10:06:09.000Z","updated_at":"2025-03-18T07:56:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"9fdb0428-1398-421e-8381-695b9f2eec27","html_url":"https://github.com/SomajitDey/redis-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SomajitDey/redis-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fredis-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fredis-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fredis-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fredis-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SomajitDey","download_url":"https://codeload.github.com/SomajitDey/redis-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomajitDey%2Fredis-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30364610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["bash","connection-pool","no-sql","redis","redis-client","resp-parser"],"created_at":"2024-10-03T13:09:17.645Z","updated_at":"2026-03-11T01:02:25.843Z","avatar_url":"https://github.com/SomajitDey.png","language":"Shell","funding_links":["https://buymeacoffee.com/SomajitDey"],"categories":[],"sub_categories":[],"readme":"# Redis Client (Bash)\r\n\r\n[![Featured](https://img.shields.io/badge/Featured%20in-redis.io-yellogreen)](https://web.archive.org/web/20240401013920/https://redis.io/resources/clients/#bash) \r\n\r\nThis project consists of \r\n\r\n1. `redis.bash` - a Bash library for [Redis](https://redis.io/) containing some useful shell-functions\r\n2. `redis-cli` - an executable Bash script implementing an interactive Redis console\r\n3. `redis-pool` - a [connection pool](https://en.wikipedia.org/wiki/Connection_pool) for Redis\r\n\r\n## Table of Contents  \n[![tocgen](https://img.shields.io/badge/Generated%20using-tocgen-blue)](https://github.com/SomajitDey/tocgen)  \n  - [Redis Client (Bash)](#redis-client-bash)  \n  - [Library usage](#library-usage)  \n      - [Low level tasks](#low-level-tasks)  \n      - [Demo / Example](#demo--example)  \n  - [CLI console](#cli-console)  \n  - [Connection pool](#connection-pool)  \n  - [Alternative(s)](#alternatives)  \n  - [Feedback, feature requests, bug report](#feedback-feature-requests-bug-report)  \n  - [Contribution](#contribution)  \n  - [Support / Sponsor](#support--sponsor)  \n  - [Acknowledgements](#acknowledgements)  \n  - [License](#license)  \n#####   \n\r\n# Library usage\r\n\r\n1. To use the library functions in your Bash script, source the library first: `source \u003cpath to redis.bash\u003e`\r\n\r\n2. Then, create a session using \r\n\r\n   ```bash\r\n   redis_connect [-h host] [-p port] [-a passwd] [-d database] [-t timeout in seconds]\r\n   ```\r\n\r\n   Instead of using options, the host, port, password, database and timeout can also be provided using the respective environment variables: `REDIS_HOST`, `REDIS_PORT`, `REDIS_AUTH`, `REDIS_DB`, `REDIS_TIMEOUT`. The timeout is the interval used by the *automatic keepalive service*. If keepalive is not required, specify a 0s timeout. The defaults are - Host: localhost ; Port: 6379 ; DB: 0 ; Timeout: 300s.\r\n\r\n3. To execute a single [Redis command](https://redis.io/commands/) in the server, and get its corresponding response, run: \r\n\r\n   ```bash\r\n   redis_exec \u003ccommmand\u003e\r\n   \r\n   # Example: redis_exec 'keys *'\r\n   ```\r\n\r\n    This sends the command to the server and then prints the server response to stderr or stdout, depending on whether the server response data-type (RESP) is \"Error\" or not. The rather trivial OK and PONG responses are not printed for redirected stdout, for developer convenience. `redis_exec` returns after reading exactly one complete RESP response from the server. The read has a 1 second timeout. If reading from or sending the command to the server fails, `redis_exec` assumes that the server got disconnected and tries to reconnect and resend the command automatically. \r\n\r\n   **Note:** If you forget to do `redis_connect` (step 1 above), then `redis_exec` will exit with error: `Failed to acquire lock 1`. In that case, simply do step 1 and then retry `redis_exec`.\r\n\r\n4. To end session with the server, simply do: `redis_disconnect`\r\n\r\n### Low level tasks\r\n\r\n`redis_read [-t \u003ctimeout\u003e]`: for parsing RESP\r\n\r\n`redis_rep [-t \u003ctimeout\u003e] [-n N]`: for reading N complete RESP responses and printing the values at stdout or stderr based on the RESP data-type(s); N=0 implies an infinite reading loop useful for reading push messages.\r\n\r\nSee documentation in `redis.bash` for details.\r\n\r\n### Demo / Example\r\n\r\nCheckout the code in `redis-cli` . It uses the client-library only.\r\n\r\n# CLI console\r\n\r\n`./redis-cli -h \u003chost\u003e -p \u003cport\u003e -a \u003cpasswd\u003e -t \u003cidle timeout s\u003e -d \u003cdatabase no.\u003e`\r\n\r\nTo quit, enter any of the following: `q` , `exit` , `quit` (case-insensitive)\r\n\r\n**Note**: If subscribed to push messages with `(P)SUBSCRIBE channel` or `MONITOR`, simply do `Ctrl-C` (i.e. ^C) followed by `Enter` to return to the normal interactive mode, i.e. get the command prompt back.\r\n\r\n# Connection pool\r\n\r\n`redis-pool` offers simple connection pooling with support for both Unix domain and TCP sockets. The local socket serves as a proxy for the remote Redis server. If the number of concurrent connections/requests to this proxy is more than what the server can support, the excess requests will be put on hold (i.e. blocking) and served whenever a spot opens up.\r\n\r\nFollowing are simple examples using Unix domain sockets. For using TCP ports instead, simply replace `path/socket` with the port number and remove the `-U` flag in `nc`:\r\n\r\n1. In one terminal :\r\n\r\n   ```bash\r\n   ./redis-pool -n \u003cmax connections\u003e -h \u003chost\u003e -p \u003cport\u003e -a \u003cpass\u003e path/socket\r\n   ```\r\n\r\n2. In another terminal: \r\n\r\n   ```bash\r\n   . redis.bash # In order to define redis_rep\r\n   \r\n   # Pipelining 2 commands in one go\r\n   echo -e \"set foo bar\\nget foo\" | nc -N -U path/socket | redis_rep -n 2\r\n   \r\n   # Activating the push protocol: pub-sub\r\n   echo \"subscribe channel\" | nc -U path/socket | redis_rep -n 0\r\n   ```\r\n\r\n3. In still another terminal: \r\n\r\n   ```bash\r\n   ./redis-cli\r\n   localhost:port_db$ publish channel hello\r\n   # Check now if you got the message in the second terminal\r\n   ```\r\n\r\n**Note:** We use `echo` with the Redis commands instead of `printf` or `echo -n`. The pool transforms trailing LF to CRLF before sending each inline command to the server. \r\n\r\n# Alternative(s)\r\n\r\nhttps://redis.io/clients#bash\r\n\r\nhttps://github.com/caquino/redis-bash\r\n\r\n# Feedback, feature requests, bug report\r\n\r\nCreate an issue at the [project repository](https://github.com/SomajitDey/redis-client) or [write to me](mailto:dey.somajit@gmail.com). \r\n\r\nIf you like this project, please consider giving it a star at [GitHub](https://github.com/SomajitDey/redis-client) to encourage me.\r\n\r\n# Contribution\r\n\r\nPRs are welcome. Please follow this minimal style guide when contributing:\r\n\r\n- No camelCase. Only under_scores.\r\n- Do, If, Case and For constructs as in `redis.bash`\r\n\r\nAlso put your name and email id in the comments section of your code-block.\r\n\r\nIf you cannot submit a PR at [GitHub](https://github.com/SomajitDey/redis-client), feel free to send me your patch over [email](mailto:dey.somajit@gmail.com). Just mention the Git commit hash in the [project repository](https://github.com/SomajitDey/redis-client) to which the patch should be applied.\r\n\r\n**Open issue:** Making the docs better.\r\n\r\n# Support / Sponsor\r\n\r\n[![Sponsor](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://buymeacoffee.com/SomajitDey)\r\n\r\n# Acknowledgements\r\n\r\nTY: @[zuiderkwast](https://github.com/zuiderkwast)\r\n\r\n# License\r\n\r\nGNU Lesser General Public License - 2.1\r\n\r\nCopyright (C) Somajit Dey, 2021","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomajitdey%2Fredis-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomajitdey%2Fredis-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomajitdey%2Fredis-client/lists"}