Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caquino/redis-bash
REDIS-BASH - Bash library to access Redis
https://github.com/caquino/redis-bash
bash bash-script redis shell-script
Last synced: 5 days ago
JSON representation
REDIS-BASH - Bash library to access Redis
- Host: GitHub
- URL: https://github.com/caquino/redis-bash
- Owner: caquino
- License: bsd-3-clause
- Created: 2011-10-13T21:44:08.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2023-01-01T22:22:13.000Z (almost 2 years ago)
- Last Synced: 2024-12-09T11:38:07.275Z (14 days ago)
- Topics: bash, bash-script, redis, shell-script
- Language: Shell
- Homepage: https://github.com/caquino/redis-bash
- Size: 80.1 KB
- Stars: 162
- Watchers: 13
- Forks: 39
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# REDIS-BASH - Bash library to access Redis Databases
[![Release](https://github.com/caquino/redis-bash/actions/workflows/release.yml/badge.svg)](https://github.com/caquino/redis-bash/actions/workflows/release.yml)
* The library comes with two examples, one generic client and a pubsub demo.
* This library has no external dependencies, using only bash built-in commands.
* The only requirement is bash to have net redirections enabled.
* The command validation is made by the server.## Using the client and the pubsub demo
### Client
```bash
$ redis-bash-cli
```Parameters:
```
-h Host - Defaults localhost.
-p Port - Defaults 6379.
-n DB - Select the database DB.
-r N - Repeat command N times.
-a PASSWORD - Authentication password
-i INTERVAL - Interval between commands
```Examples:
```bash
$ redis-bash-cli -h localhost SET testkey 1234
OK$ redis-bash-cli -h localhost GET testkey
1234$ redis-bash-cli -h localhost PING
PONG$ redis-bash-cli -h localhost -r 5 PING
PONG
PONG
PONG
PONG
PONG$ redis-bash-cli -h localhost WRONGCOMMAND test
ERR unknown command 'WRONGCOMMAND'
```Authenticated requests:
```bash
$ redis-bash-cli -h localhost PING
ERR operation not permitted$ redis-bash-cli -h localhost -a test PING
PONG
```### Pubsub
```bash
$ redis-pubsub-test
```Parameters:
```bash
-h Host - Defaults localhost.
-p Port - Defaults 6379.
CHANNEL - Channel to subscribe
```## Pubsub demo
In one shell run the command:```bash
$ redis-pubsub-test test
```In another shell run the command:
```bash
$ redis-bash-cli -h localhost -p 6379 PUBLISH test "Hello World."
```# Using the Library in your code
The library have a single function to handle the redis communication.```bash
$ redis-client
```* FD: file descriptor to access the redis database
* COMMAND: command to be sent to the server, can be blank to do read operation.Using the library:
```bash
#!/bin/bash
source redis-bash-lib # include the library
exec 6<>/dev/tcp/localhost/6379 # open the connection
redis-client 6 SET test 1234 # do a SET operation
exec 6>&- # close the connection
```# TODO
* manual page
* tests
* documentation# LICENSE
* BSD# Debian Package
* To build the debian/ubuntu package use dpkg-buildpackage.# CONTACT
* email: cassianoaquino at me.com
* twitter: @syshero
* blog: http://syshero.org/# THANKS
* Andre Ferraz - Debian Package
* Juliano Martinez - Idea to handle socket disconnections on the pubsub demo# TESTED
* Debian squeeze 6.0.X - GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
* Mac OS X Lion 10.7.X - GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)# PERFORMANCE
This test has no intent to be a complete benchmark, but only to show the diference between both clients.
```bash
$ time redis-bash-cli -h 192.168.86.1 -r 10 PING > /dev/nullreal0m0.027s
user0m0.000s
sys0m0.024s$ time redis-cli -h 192.168.86.1 -r 10 PING > /dev/null
real0m0.012s
user0m0.000s
sys0m0.008s
```