1 Star 0 Fork 0

zhuchance / kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"log"
"github.com/xyproto/simpleredis"
)
func main() {
// Check if the redis service is up
if err := simpleredis.TestConnection(); err != nil {
log.Fatalln("Could not connect to Redis. Is the service up and running?")
}
// Use instead for testing if a different host/port is up.
// simpleredis.TestConnectionHost("localhost:6379")
// Create a connection pool, connect to the given redis server
pool := simpleredis.NewConnectionPool()
// Use this for connecting to a different redis host/port
// pool := simpleredis.NewConnectionPoolHost("localhost:6379")
// For connecting to a different redis host/port, with a password
// pool := simpleredis.NewConnectionPoolHost("password@redishost:6379")
// Close the connection pool right after this function returns
defer pool.Close()
// Create a list named "greetings"
list := simpleredis.NewList(pool, "greetings")
// Add "hello" to the list, check if there are errors
if list.Add("hello") != nil {
log.Fatalln("Could not add an item to list!")
}
// Get the last item of the list
if item, err := list.GetLast(); err != nil {
log.Fatalln("Could not fetch the last item from the list!")
} else {
log.Println("The value of the stored item is:", item)
}
// Remove the list
if list.Remove() != nil {
log.Fatalln("Could not remove the list!")
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v1.2.0-alpha.8

搜索帮助

344bd9b3 5694891 D2dac590 5694891