代码拉取完成,页面将自动刷新
// Copyright 2016 CodisLabs. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package redis
import "fmt"
type RespType byte
const (
TypeString RespType = '+'
TypeError RespType = '-'
TypeInt RespType = ':'
TypeBulkBytes RespType = '$'
TypeArray RespType = '*'
)
func (t RespType) String() string {
switch t {
case TypeString:
return "<string>"
case TypeError:
return "<error>"
case TypeInt:
return "<int>"
case TypeBulkBytes:
return "<bulkbytes>"
case TypeArray:
return "<array>"
default:
return fmt.Sprintf("<unknown-0x%02x>", byte(t))
}
}
type Resp struct {
Type RespType
Value []byte
Array []*Resp
}
func (r *Resp) IsString() bool {
return r.Type == TypeString
}
func (r *Resp) IsError() bool {
return r.Type == TypeError
}
func (r *Resp) IsInt() bool {
return r.Type == TypeInt
}
func (r *Resp) IsBulkBytes() bool {
return r.Type == TypeBulkBytes
}
func (r *Resp) IsArray() bool {
return r.Type == TypeArray
}
func NewString(value []byte) *Resp {
r := &Resp{}
r.Type = TypeString
r.Value = value
return r
}
func NewError(value []byte) *Resp {
r := &Resp{}
r.Type = TypeError
r.Value = value
return r
}
func NewErrorf(format string, args ...interface{}) *Resp {
return NewError([]byte(fmt.Sprintf(format, args...)))
}
func NewInt(value []byte) *Resp {
r := &Resp{}
r.Type = TypeInt
r.Value = value
return r
}
func NewBulkBytes(value []byte) *Resp {
r := &Resp{}
r.Type = TypeBulkBytes
r.Value = value
return r
}
func NewArray(array []*Resp) *Resp {
r := &Resp{}
r.Type = TypeArray
r.Array = array
return r
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。