Go 使用redis
go redis库
Go中的redis库,这两个是使用比较多的
第一个:redigo
库下载地址
https://github.com/garyburd/redigo
库对应文档说明
https://godoc.org/github.com/garyburd/redigo/redis
下载建议使用命令(cmd切换到gopath目录的src目录下 使用
go get github.com/garyburd/redigo/redis
命令来下载到gopath/src目录下,用链接下载的方式下载完以后,要确保库的路径gopath/src,确保三方库在gopath/src路径下,其目的主要是方便引用)
第二个:go-redis
库下载地址
https://github.com/go-redis/redis
库对应文档说明
https://godoc.org/github.com/go-redis/redis
同上,建议用命令的方式去获取三方库
go get -u github.com/go-redis/redis
github.com.gomodule.redigo.redis
第三个:gomodule/
库下载地址
https://github.com/gomodule/redigo
同上,建议用命令的方式去获取三方库
go get github.com/gomodule/redigo
第三个没怎么用,跟第一个其实差不多,都有连接池,订阅模式,唯一不同的是,gomodule里面有关于redis的用法举例,里面有xx_example_test.go,但是这两个都不支持集群操作,仅直接支持普通的客服端操作,集群需要自己去实现,不过也可以在下面两个中选一个来支持集群
https://github.com/wuxibin89/redis-go-cluster
https://github.com/gitstliu/go-redis-cluster
第二个go-redis直接支持集群,自己配好redis主从后,就可以直接使用三方的API操作集群,也支持普通的客服端。
关于第二个go-redis的集群操作,请点击这里