当前位置: 首页>>代码示例>>Golang>>正文


Golang Client.Quit方法代码示例

本文整理汇总了Golang中github.com/gosexy/redis.Client.Quit方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Quit方法的具体用法?Golang Client.Quit怎么用?Golang Client.Quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/gosexy/redis.Client的用法示例。


在下文中一共展示了Client.Quit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: spawnConsumer

func spawnConsumer() error {
	var err error
	var consumer *redis.Client

	consumer = redis.New()

	err = consumer.Connect(host, port)

	if err != nil {
		log.Fatalf("Consumer failed to connect: %s\n", err.Error())
		return err
	}

	log.Println("Consumer connected to redis-server.")

	rec := make(chan []string)

	log.Printf("Waiting for rec channel. Ctrl + C to quit.\n")
	go consumer.Subscribe(rec, "channel")

	var ls []string

	for {
		ls = <-rec
		log.Printf("Consumer received: %v\n", strings.Join(ls, ", "))
	}

	consumer.Quit()

	return nil
}
开发者ID:22morph,项目名称:redis,代码行数:31,代码来源:main.go

示例2: spawnPublisher

func spawnPublisher() error {
	var err error
	var publisher *redis.Client

	publisher = redis.New()

	err = publisher.Connect(host, port)

	if err != nil {
		log.Fatalf("Publisher failed to connect: %s\n", err.Error())
		return err
	}

	log.Println("Publisher connected to redis-server.")

	log.Println("Publishing some messages...")

	publisher.Publish("channel", "Hello world!")
	publisher.Publish("channel", "Do you know how to count?")

	for i := 0; i < 3; i++ {
		publisher.Publish("channel", i)
	}

	log.Printf("Closing publisher.\n")

	publisher.Quit()

	return nil
}
开发者ID:22morph,项目名称:redis,代码行数:30,代码来源:main.go

示例3: testConn

func (this *redisPool) testConn(conn *redis.Client) error {
	if _, err := conn.Ping(); err != nil {
		conn.Quit()
		return err
	}

	return nil
}
开发者ID:jmcarbo,项目名称:smtpd-1,代码行数:8,代码来源:redis_store.go

示例4: Close

func (this *redisPool) Close(conn *redis.Client) {
	select {
	case this.connections <- conn:
		return
	default:
		conn.Quit()
	}
}
开发者ID:jmcarbo,项目名称:smtpd-1,代码行数:8,代码来源:redis_store.go

示例5: redisGetHandler

func redisGetHandler(w http.ResponseWriter, r *http.Request) {
	var client *redis.Client
	var err error
	client = redis.New()
	err = client.Connect("localhost", 6379)
	if err != nil {
		fmt.Fprintf(w, "/connect fail/")
		return
	}
	defer client.Quit()

	key := r.FormValue("key")

	s, err := client.Get(key)

	if err != nil {
		fmt.Fprintf(w, "/values: is empty%s/", s)
		return
	}

	fmt.Fprintf(w, "/values:%s/", s)
}
开发者ID:redage,项目名称:apps,代码行数:22,代码来源:test.go

示例6: redisSetHandler

func redisSetHandler(w http.ResponseWriter, r *http.Request) {
	value := r.FormValue("value")
	key := r.FormValue("key")
	fmt.Fprintf(w, "/set key:%s,value:%s/", key, value)
	var err error
	var client *redis.Client
	client = redis.New()
	err = client.Connect("localhost", 6379)
	if err != nil {
		fmt.Fprintf(w, "/connect fail/")
		return
	}
	defer client.Quit()

	client.Set(key, value)

	if err != nil {
		fmt.Fprintf(w, "/set values: is empty%s/")
		return
	}

	fmt.Fprintf(w, "/set key:%s,value:%s/", key, value)
}
开发者ID:redage,项目名称:apps,代码行数:23,代码来源:test.go


注:本文中的github.com/gosexy/redis.Client.Quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。