當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.Quit方法代碼示例

本文整理匯總了Golang中menteslibres/net/gosexy/redis.Client.Quit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Quit方法的具體用法?Golang Client.Quit怎麽用?Golang Client.Quit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在menteslibres/net/gosexy/redis.Client的用法示例。


在下文中一共展示了Client.Quit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: spawnConsumer

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

	consumer = redis.New()

	err = consumer.ConnectNonBlock(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("Consumer will read exactly 6 messages before quitting.\n")

	go consumer.Subscribe(rec, "channel")

	var ls []string

	for j := 0; j < 6; j++ {
		ls = <-rec
		log.Printf("Consumer received message[%d]: %v\n", j, strings.Join(ls, ", "))
	}

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

	consumer.Quit()

	return nil
}
開發者ID:carriercomm,項目名稱:redis-3,代碼行數:34,代碼來源: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:carriercomm,項目名稱:redis-3,代碼行數:30,代碼來源:main.go

示例3: PutRedisClient

func PutRedisClient(client *redis.Client) {
	if RedisClientPool == nil {
		RedisClientPool = make(chan *redis.Client, MAX_POOL_SIZE)
	}
	if len(RedisClientPool) >= MAX_POOL_SIZE {
		client.Quit()
		return
	}
	RedisClientPool <- client
}
開發者ID:panjianbo,項目名稱:gosrc,代碼行數:10,代碼來源:redis_pool.go

示例4: main

func main() {
	var client *redis.Client

	client = redis.New()
	client.Connect("localhost", 6379)

	s, _ := client.Ping()
	fmt.Println(s)
	client.Incr("hello")
	s, _ = client.Get("hello")
	fmt.Println(s)
	client.Quit()
}
開發者ID:panjianbo,項目名稱:gosrc,代碼行數:13,代碼來源:redis.go


注:本文中的menteslibres/net/gosexy/redis.Client.Quit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。