Golang access to Redis first experience

Source: Internet
Author: User

Go language client in the Redis official network has a lot of L client, personal feeling Redigo use more humane, important is the source code structure is very clear, it is important to support pipeline, publish and subscribe, connection pool and so on, so I chose Redigo as an attempt.

Installation of 1.redigo

Terminal operation:go get github.com/garyburd/redigo/redis ,安装完成后在$GOPATH/src下有相关的文件目录

这是正常的安装方式,不知道什么原因,这块我死活安装不成功.

No way, download the Redigo-master.zip project package directly from GitHub online and copy the Redis folder directly to the $gopath/src/github.com/garyburd/redigo

2. Test Redigo

The virtual machine starts the Redis service, opens Liteide, and adds a go file:

Redistest Project Main.gopackage mainimport ("FMT" "Github.com/garyburd/redigo/redis") func main () {c, err: = Redis. Dial ("TCP", "192.168.74.128:6379") if err! = Nil {fmt. PRINTLN (ERR) return}//password authorization c. Do ("AUTH", "123456") c.do ("SET", "a", 134) A, err: = Redis. Int (C.do ("GET", "a")) FMT. Println (a) defer c.close ()}

Run after compiling the build and print out the correct results.

Golang access to Redis first experience

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.