Git Product home page Git Product logo

bluto's Introduction

Go GoDoc Go Report Card CII Best Practices Coverage

Bluto

Bluto is a golang implementation of redis client based on Redigo.The client manages a connection pool for each node, uses goroutine to execute as concurrently as possible, which leads to its high efficiency and low latency.

Supported:

  • Most commands of keys, strings, lists, sets, sorted sets, hashes.

Documentation

API Reference

Installation

Install Bluto with go tool:

    go get github.com/alibaba-go/bluto/...

Usage

To use redis cluster, you need import the package and create a new bluto client with an options:

import ""

bluto, err := bluto.New(
    &bluto.config{
    Address:              "localhost:6379",
    Password              "password"
    ConnectTimeoutSeconds: 10,
    ReadTimeoutSeconds:    10,
    })

Basic

Bluto gives you a commander by calling Borrow() which is interface to run redis commands exp.(GET, SELECT , ...) over a pool of redis connection which simplify all the managements of pool.

RESTRICTION: Please be sure the first argument in commander's args is result and all commands should ends with Commit().The optional arguments are passed as variadic args.

See full redis commands:

bluto.Borrow().Set(&setResult, "key", "value", SetOptionKEEPTTL{}).Commit()
bluto.Borrow().Get(&getResult, "key").Commit()
bluto.Borrow().Incr(&incrResult, "key").Commit()

You can also chain redis commands like this:

bluto.Borrow().Select(&selectResult, 2).Set(&setResult, "key", "value",SetOptionKEEPTTL{}).Incr(&incrResult, "key").Commit()
bluto.Borrow().Select(&selectResult, 2).Get(&getResult, "key").Decr(&decrResult, "key").Del(&delResult, "key").Commit()

Also, you can use Values and Scan to convert replies to multiple values with different types.

Command's Options

You can pass options as variadic args as last arguments. The Options for each command is interface which is satisfied by defined option structs. You can pass multiple options like this:

bluto.Borrow().Set(&setResult, "key", "value", SetOptionEX{EX:1}, SetOptionNX{}, SetOptionKEEPTTL{}).Commit()

For more advanced example look at example

Contributing

See CONTRIBUTING.md.

Contact

Bug reports and feature requests are welcome. If you have any question, please email us at [email protected].

License

Released under MIT License

bluto's People

Contributors

rezkam avatar

Stargazers

errir 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.