标签:pre result local put == 执行命令 new set ping
redigo有点像hiredis,只提供了最基本的连接和执行命令接口。
找到个不错的redis库:
https://github.com/go-redis/redis
func ExampleNewClient() { client := redis.NewClient(&redis.Options{ Addr: "localhost:6379", Password: "", // no password set DB: 0, // use default DB }) pong, err := client.Ping().Result() fmt.Println(pong, err) // Output: PONG <nil> } func ExampleClient() { err := client.Set("key", "value", 0).Err() if err != nil { panic(err) } val, err := client.Get("key").Result() if err != nil { panic(err) } fmt.Println("key", val) val2, err := client.Get("key2").Result() if err == redis.Nil { fmt.Println("key2 does not exists") } else if err != nil { panic(err) } else { fmt.Println("key2", val2) } // Output: key value // key2 does not exists }
标签:pre result local put == 执行命令 new set ping
原文地址:http://www.cnblogs.com/zapline/p/7209216.html