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


Golang protocol.McResponse類代碼示例

本文整理匯總了Golang中github.com/luxuan/go-memcached-server/protocol.McResponse的典型用法代碼示例。如果您正苦於以下問題:Golang McResponse類的具體用法?Golang McResponse怎麽用?Golang McResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: BFIncr

func (h *Handler) BFIncr(req *protocol.McRequest, res *protocol.McResponse) error {
	if exist := h.Incr(req.Key); exist {
		res.Response = "1"
	} else {
		res.Response = "0"
	}
	return nil
}
開發者ID:shitfSign,項目名稱:go-bloomfilter,代碼行數:8,代碼來源:server.go

示例2: DefaultGet

func DefaultGet(req *protocol.McRequest, res *protocol.McResponse) error {
	for _, key := range req.Keys {
		value := dict[key]
		// TODO missed
		res.Values = append(res.Values, protocol.McValue{key, "0", value})
	}
	res.Response = "END"
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:9,代碼來源:defaultHandler.go

示例3: BFGet

func (h *Handler) BFGet(req *protocol.McRequest, res *protocol.McResponse) error {
	var b []byte
	for _, key := range req.Keys {
		if exist := h.Get(key); exist {
			b = []byte("1")
		} else {
			b = []byte("0")
		}
		res.Values = append(res.Values, protocol.McValue{key, "0", b})
	}
	res.Response = "END"
	return nil
}
開發者ID:shitfSign,項目名稱:go-bloomfilter,代碼行數:13,代碼來源:server.go

示例4: DefaultDelete

func DefaultDelete(req *protocol.McRequest, res *protocol.McResponse) error {
	count := 0
	for _, key := range req.Keys {
		if _, exists := dict[key]; exists {
			delete(dict, key)
			count++
		}
	}
	if count > 0 {
		res.Response = "DELETED"
	} else {
		res.Response = "NOT_FOUND"
	}
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:15,代碼來源:defaultHandler.go

示例5: DefaultSet

func DefaultSet(req *protocol.McRequest, res *protocol.McResponse) error {
	key := req.Key
	value := req.Value
	dict[key] = value

	res.Response = "STORED"
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:8,代碼來源:defaultHandler.go

示例6: DefaultIncr

func DefaultIncr(req *protocol.McRequest, res *protocol.McResponse) error {
	key := req.Key
	increment := req.Increment
	var base int64
	if value, exists := dict[key]; exists {
		var err error
		base, err = strconv.ParseInt(string(value), 10, 64)
		if err != nil {
			return err
		}
	}

	value := strconv.FormatInt(base+increment, 10)
	dict[key] = []byte(value)

	res.Response = value
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:18,代碼來源:defaultHandler.go

示例7: DefaultVersion

func DefaultVersion(req *protocol.McRequest, res *protocol.McResponse) error {
	res.Response = "VERSION simple-memcached-0.1"
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:4,代碼來源:defaultHandler.go

示例8: DefaultFlushAll

func DefaultFlushAll(req *protocol.McRequest, res *protocol.McResponse) error {
	// TODO clear map
	res.Response = "OK"
	return nil
}
開發者ID:shitfSign,項目名稱:go-memcached-server,代碼行數:5,代碼來源:defaultHandler.go

示例9: BFVersion

func (h *Handler) BFVersion(req *protocol.McRequest, res *protocol.McResponse) error {
	res.Response = "VERSION simple-memcached-0.1"
	return nil
}
開發者ID:shitfSign,項目名稱:go-bloomfilter,代碼行數:4,代碼來源:server.go

示例10: BFSet

func (h *Handler) BFSet(req *protocol.McRequest, res *protocol.McResponse) error {
	h.Set(req.Key)
	res.Response = "STORED"
	return nil
}
開發者ID:shitfSign,項目名稱:go-bloomfilter,代碼行數:5,代碼來源:server.go


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