本文整理汇总了Golang中github.com/luxuan/go-memcached-server/protocol.McResponse.Response方法的典型用法代码示例。如果您正苦于以下问题:Golang McResponse.Response方法的具体用法?Golang McResponse.Response怎么用?Golang McResponse.Response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/luxuan/go-memcached-server/protocol.McResponse
的用法示例。
在下文中一共展示了McResponse.Response方法的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: 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
}
示例3: DefaultSet
func DefaultSet(req *protocol.McRequest, res *protocol.McResponse) error {
key := req.Key
value := req.Value
dict[key] = value
res.Response = "STORED"
return nil
}
示例4: 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
}
示例5: 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
}
示例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
}