Giter Club home page Giter Club logo

redis-protocol-example's Introduction

redis-protocol-example

用 Go 来了解一下 Redis 通讯协议,本项目支持 Redis 的五种通讯协议,如下:

  • 状态回复(status reply)
  • 错误回复(error reply)
  • 整数回复(integer reply)
  • 批量回复(bulk reply)
  • 多条批量回复(multi bulk reply)

安装

$ go get github.com/EDDYCJY/redis-protocol-example

使用

Status Reply

$ go run main.go SET test01 value01
2018/06/06 21:29:07 Reply: OK
2018/06/06 21:29:07 Command: +OK

Error Reply

$ go run main.go error
2018/06/06 22:20:39 Reply: ERR unknown command 'error'
2018/06/06 22:20:39 Command: -ERR unknown command 'error'

Integer Reply

$ go run main.go EXPIRE test01 3600
2018/06/06 22:18:00 Reply: 1
2018/06/06 22:18:00 Command: :1

Bulk Reply

$ go run main.go GET test01
2018/06/06 22:13:36 Reply: value01
2018/06/06 22:13:36 Command: $7
value01

Multi Bulk Reply

$ go run main.go LPUSH test-multi 01
2018/06/06 22:23:50 Reply: 1
2018/06/06 22:23:50 Command: :1

$ go run main.go LPUSH test-multi 02
2018/06/06 22:23:54 Reply: 2
2018/06/06 22:23:54 Command: :2

$ go run main.go LPUSH test-multi 03
2018/06/06 22:23:57 Reply: 3
2018/06/06 22:23:57 Command: :3

$ go run main.go LRANGE test-multi 0 10
2018/06/06 22:24:10 Reply: [03 02 01]
2018/06/06 22:24:10 Command: *3
$2
03
$2
02
$2
01

redis-protocol-example's People

Contributors

eddycjy avatar

Watchers

James Cloos 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.