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


Golang Prot.Delete方法代碼示例

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


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

示例1: communicator

func communicator(prot common.Prot, conn net.Conn, tasks <-chan *common.Task, metrics chan<- metric, comms *sync.WaitGroup) {
	r := rand.New(rand.NewSource(common.RandSeed()))
	rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))

	for item := range tasks {
		var err error
		start := timer.Now()

		switch item.Cmd {
		case common.Set:
			err = prot.Set(rw, item.Key, item.Value)
		case common.Add:
			err = prot.Add(rw, item.Key, item.Value)
		case common.Replace:
			err = prot.Replace(rw, item.Key, item.Value)
		case common.Append:
			err = prot.Append(rw, item.Key, item.Value)
		case common.Prepend:
			err = prot.Prepend(rw, item.Key, item.Value)
		case common.Get:
			_, err = prot.Get(rw, item.Key)
		case common.Gat:
			_, err = prot.GAT(rw, item.Key)
		case common.Bget:
			bk := batchkeys(r, item.Key)
			_, err = prot.BatchGet(rw, bk)
			bkpool.Put(bk)
		case common.Delete:
			err = prot.Delete(rw, item.Key)
		case common.Touch:
			err = prot.Touch(rw, item.Key)
		}

		if err != nil {
			// don't print get misses, adds not stored, and replaces not stored
			if !isMiss(err) {
				fmt.Printf("Error performing operation %s on key %s: %s\n", item.Cmd, item.Key, err.Error())
			}
			// if the socket was closed, stop. Otherwise keep on hammering.
			if err == io.EOF {
				break
			}
		}

		m := metricPool.Get().(metric)
		m.d = timer.Since(start)
		m.op = item.Cmd
		m.miss = isMiss(err)
		metrics <- m

		taskPool.Put(item)
	}

	conn.Close()
	comms.Done()
}
開發者ID:Netflix,項目名稱:rend,代碼行數:56,代碼來源:blast.go

示例2: communicator

func communicator(prot common.Prot, conn net.Conn, tasks <-chan *common.Task, metrics chan<- metric, comms *sync.WaitGroup) {
	r := rand.New(rand.NewSource(common.RandSeed()))
	rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))

	for item := range tasks {
		var err error
		start := time.Now()

		switch item.Cmd {
		case common.Set:
			err = prot.Set(rw, item.Key, item.Value)
		case common.Get:
			err = prot.Get(rw, item.Key)
		case common.Gat:
			err = prot.GAT(rw, item.Key)
		case common.Bget:
			err = prot.BatchGet(rw, batchkeys(r, item.Key))
		case common.Delete:
			err = prot.Delete(rw, item.Key)
		case common.Touch:
			err = prot.Touch(rw, item.Key)
		}

		if err != nil {
			if err != binprot.ErrKeyNotFound {
				fmt.Printf("Error performing operation %s on key %s: %s\n", item.Cmd, item.Key, err.Error())
			}
			// if the socket was closed, stop. Otherwise keep on hammering.
			if err == io.EOF {
				break
			}
		}

		metrics <- metric{
			d:  time.Since(start),
			op: item.Cmd,
		}
	}

	conn.Close()
	comms.Done()
}
開發者ID:hardiku,項目名稱:rend,代碼行數:42,代碼來源:blast.go


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