本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例7: DefaultVersion
func DefaultVersion(req *protocol.McRequest, res *protocol.McResponse) error {
res.Response = "VERSION simple-memcached-0.1"
return nil
}
示例8: DefaultFlushAll
func DefaultFlushAll(req *protocol.McRequest, res *protocol.McResponse) error {
// TODO clear map
res.Response = "OK"
return nil
}
示例9: BFVersion
func (h *Handler) BFVersion(req *protocol.McRequest, res *protocol.McResponse) error {
res.Response = "VERSION simple-memcached-0.1"
return nil
}
示例10: BFSet
func (h *Handler) BFSet(req *protocol.McRequest, res *protocol.McResponse) error {
h.Set(req.Key)
res.Response = "STORED"
return nil
}