在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
package main import ( "fmt" "github.com/gomodule/redigo/redis" ) func main() { conn,err := redis.Dial("tcp","127.0.0.1:6379") if err != nil{ fmt.Printf("connect to redis fail [%s]",err) return } //退出的时候关闭链接 defer conn.Close() _ ,err = conn.Do("set","testKey","testVaule") if err != nil{ fmt.Printf("redis opr fail [%s]",err) return } testVaule, err := redis.String(conn.Do("GET", "testKey")) if err != nil { fmt.Println("redis get failed:", err) } else { fmt.Printf("Get testKey: %v \n", testVaule) } }
|
请发表评论