simple_redis_client

0.2.5 • Public • Published

Simple Redis Client

It's a pretty simple and basic redis client, designed to be very fast and keep all code simple.

How to install it?

npm install simple_redis_client

How to use?

var redisClient = require("simple_redis_client")
var myClient = redisClient.createClient(6379,"127.0.0.1") 
myClient.on("ready",function(){
    myClient.execute("set","hello","world",function(err){
        myClient.execute("get","hello",function(err,data){
            console.log(data.toString())
        })
    })
})

Why to Use?

  • It's extremly fast using buffers compared to other node.js redis clients
  • It has an standar interface that could support any new command without code modifications (ever than the protocol continue being the same)
  • Only 192 lines of code for the client
  • Based on the native c++ hiredis parser (https://github.com/pietern/hiredis-node)

Advance Options

'createClient' support 3 arguments 'host','port' and 'options', options is optional, if you want to use it, It could have next options

var options={
    return_buffers: Boolean (decide if the return value will be string or buffer, default: true),
    recheck_time: Number (If a disconnect occurs, It's the time in miliseconds between recoinnect tries, default: 1000),
    connectTimeout:  Number (It's the time before emit an error while the connection is creating, default: undefined),
}

Pub/Sub

var redisClient = require("simple_redis_client")
var pub = redisClient.createClient(6379,"127.0.0.1") 
var sub = redisClient.createClient(6379,"127.0.0.1") 
sub.on("message",function(channel, message){
    console.log("My Channel: "+channel+", My message: "+message)
})
sub.on("pmessage",function(pattern, channel, message){
    console.log("My pattern: "+pattern+", My channel: "+channel+", My message: "+message)
})

//On clients ready
sub.execute("SUBSCRIBE","test",function(err){
    sub.execute("PSUBSCRIBE","t*",function(err){
        sub.execute("PUBLISH","test","test message",function(err){
        })
    })
})

Benchmarks

npm install metrics
node multi_bench.js

Readme

Keywords

none

Package Sidebar

Install

npm i simple_redis_client

Weekly Downloads

0

Version

0.2.5

License

none

Last publish

Collaborators

  • geisbruch
  • marcosnils
  • xetorthio