在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
package main import ( "fmt" "github.com/garyburd/redigo/redis" ) var pool *redis.Pool func init() { pool = &redis.Pool{ Dial: func() (redis.Conn, error) { setPasswd := redis.DialPassword("123456") return redis.Dial("tcp", "localhost:6379", setPasswd) }, MaxIdle: 8, MaxActive: 0, IdleTimeout: 100, } } func main() { conn := pool.Get() defer conn.Close() _, err := conn.Do("set", "name", "wang") if err !=nil{ fmt.Println(err) return } reply, err := redis.String(conn.Do("get", "name")) if err !=nil{ fmt.Println(err) return } fmt.Println(reply) }
|
请发表评论