Giter Site home page Giter Site logo

go-redis_pool's Introduction

go-redis_pool

Redis Connection Pool written in GO

Install

go get -u "github.com/gnagel/go-redis_pool/redis_pool"

GO Usage

import "github.com/gnagel/go-redis_pool/redis_pool"
import redis "github.com/fzzy/radix/redis"

// Setup the pool
urls := []string{"127.0.0.1:6379"}
mode := redis_pool.LAZY // SIMPLE, AGRESSIVE, etc
pool := redis_pool.NewPool(mode, urls)

// Pop a Redis connection from the pool
factory := pool.Pop();
defer pool.Push(factory)

// Get the redis client from the factory
// This will re-connect if the client was previously disconnected
client, err := factory.Client()

// No connection available!
if  nil != err {
	panic(err)
}

// Ping the server
client.Append("ping")
// Get the response
reply := client.GetReply()

// Connection error? Then tell the factory to invalidate the Redis connection
if nil != reply.Err {
	// Close the connection
	factory.Close(reply.Err)
	
	// Exit your test/go routine/app/etc here
	return reply.Err
}

// ...
// ...
// ...

Authors:

Glenn Nagel [email protected], [email protected]

Credits:

Juhani Åhman's redis implementation rocks

go-redis_pool's People

Contributors

gnagel avatar

Watchers

 avatar  avatar

Forkers

wbteve

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.