Giter VIP home page Giter VIP logo

redis-bash's Introduction

REDIS-BASH - Bash library to access Redis Databases

  • 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

redis-bash-cli <PARAMETERS> <COMMAND> <ARGUMENTS>

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:

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:

redis-bash-cli -h localhost PING
ERR operation not permitted

redis-bash-cli -h localhost -a test PING
PONG

Pubsub

redis-pubsub-test <PARAMETERS> <CHANNEL>

Parameters:

-h Host - Defaults localhost.
-p Port - Defaults 6379.
CHANNEL - Channel to subscribe

Pubsub demo

In one shell run the command:

redis-pubsub-test test

In another shell run the command:

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.

redis-client <FD> <COMMAND>
  • 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:

#!/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: @djserdan

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.

time redis-bash-cli -h 192.168.86.1 -r 10 PING > /dev/null

real0m0.027s
user0m0.000s
sys0m0.024s

time redis-cli -h 192.168.86.1 -r 10 PING > /dev/null

real0m0.012s
user0m0.000s
sys0m0.008s

redis-bash's People

Contributors

caquino avatar shalupov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.