本文整理汇总了Golang中github.com/reborndb/go/redis/resp.NewBulkBytes函数的典型用法代码示例。如果您正苦于以下问题:Golang NewBulkBytes函数的具体用法?Golang NewBulkBytes怎么用?Golang NewBulkBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewBulkBytes函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ZScoreCmd
// ZSCORE key member
func ZScoreCmd(s Session, args [][]byte) (redis.Resp, error) {
if v, ok, err := s.Store().ZScore(s.DB(), args); err != nil {
return toRespError(err)
} else if !ok {
return redis.NewBulkBytes(nil), nil
} else {
return redis.NewBulkBytes(store.FormatFloat(v)), nil
}
}
开发者ID:CowLeo,项目名称:qdb,代码行数:10,代码来源:zset.go
示例2: HGetCmd
// HGET key field
func HGetCmd(s Session, args [][]byte) (redis.Resp, error) {
if b, err := s.Store().HGet(s.DB(), args); err != nil {
return toRespError(err)
} else {
return redis.NewBulkBytes(b), nil
}
}
开发者ID:cuiwm,项目名称:reborn,代码行数:8,代码来源:hash.go
示例3: EchoCmd
// ECHO text
func EchoCmd(s Session, args [][]byte) (redis.Resp, error) {
if len(args) != 1 {
return toRespErrorf("len(args) = %d, expect = 1", len(args))
}
return redis.NewBulkBytes(args[0]), nil
}
开发者ID:vebin,项目名称:reborn,代码行数:8,代码来源:misc.go
示例4: InfoCmd
// INFO [section]
func InfoCmd(s Session, args [][]byte) (redis.Resp, error) {
if len(args) != 0 && len(args) != 1 {
return toRespErrorf("len(args) = %d, expect = 0|1", len(args))
}
c, _ := s.(*conn)
if c == nil {
return nil, errors.New("invalid connection")
}
section := "all"
if len(args) == 1 {
section = strings.ToLower(string(args[0]))
}
var b bytes.Buffer
switch section {
case "database":
c.h.infoDataBase(&b)
case "config":
c.h.infoConfig(&b)
case "clients":
c.h.infoClients(&b)
case "replication":
c.h.infoReplication(&b)
default:
// all
c.h.infoAll(&b)
}
fmt.Fprintf(&b, "\r\n")
return redis.NewBulkBytes(b.Bytes()), nil
}
开发者ID:vebin,项目名称:reborn,代码行数:36,代码来源:misc.go
示例5: ZIncrByCmd
// ZINCRBY key delta member
func ZIncrByCmd(s Session, args [][]byte) (redis.Resp, error) {
if v, err := s.Store().ZIncrBy(s.DB(), args); err != nil {
return toRespError(err)
} else {
return redis.NewBulkBytes(store.FormatFloat(v)), nil
}
}
开发者ID:CowLeo,项目名称:qdb,代码行数:8,代码来源:zset.go
示例6: LIndexCmd
// LINDEX key index
func LIndexCmd(s Session, args [][]byte) (redis.Resp, error) {
if v, err := s.Store().LIndex(s.DB(), args); err != nil {
return toRespError(err)
} else {
return redis.NewBulkBytes(v), nil
}
}
开发者ID:cuiwm,项目名称:reborn,代码行数:8,代码来源:list.go
示例7: SetCmd
// SET key value [EX seconds] [PX milliseconds] [NX|XX]
func SetCmd(s Session, args [][]byte) (redis.Resp, error) {
if err := s.Store().Set(s.DB(), args); err != nil && errors2.ErrorNotEqual(err, store.ErrSetAborted) {
return toRespError(err)
} else if errors2.ErrorEqual(err, store.ErrSetAborted) {
return redis.NewBulkBytes(nil), nil
} else {
return redis.NewString("OK"), nil
}
}
开发者ID:CowLeo,项目名称:qdb,代码行数:10,代码来源:string.go
示例8: ZRevRankCmd
// ZREVRANK key member
func ZRevRankCmd(s Session, args [][]byte) (redis.Resp, error) {
if v, err := s.Store().ZRevRank(s.DB(), args); err != nil {
return toRespError(err)
} else if v >= 0 {
return redis.NewInt(v), nil
} else {
return redis.NewBulkBytes(nil), nil
}
}
开发者ID:CowLeo,项目名称:qdb,代码行数:10,代码来源:zset.go
示例9: DumpCmd
// DUMP key
func DumpCmd(s Session, args [][]byte) (redis.Resp, error) {
if x, err := s.Store().Dump(s.DB(), args); err != nil {
return toRespError(err)
} else if dump, err := rdb.EncodeDump(x); err != nil {
return toRespError(err)
} else {
return redis.NewBulkBytes(dump), nil
}
}
开发者ID:CowLeo,项目名称:qdb,代码行数:10,代码来源:keys.go
示例10: RegisterBulkReply
func RegisterBulkReply(name string, f CommandBulkStringFunc, flag CommandFlag) {
v := func(s Session, args [][]byte) (redis.Resp, error) {
r, err := f(s, args)
if err != nil {
return toRespError(err)
}
return redis.NewBulkBytes(r), nil
}
register(name, v, flag)
}
开发者ID:CowLeo,项目名称:qdb,代码行数:11,代码来源:command.go
示例11: testReplication
func (s *testReplSuite) testReplication(c *C, master testReplNode, slave testReplNode) {
// first let both stop replication
s.doCmdMustOK(c, master.Port(), "SLAVEOF", "NO", "ONE")
s.doCmdMustOK(c, slave.Port(), "SLAVEOF", "NO", "ONE")
s.doCmdMustOK(c, master.Port(), "SET", "a", "100")
offset := int64(-1)
// slaveof, will do full sync first, must support psync
nc := slave.Slaveof(c, master.Port())
defer nc.Close(c)
s.waitAndCheckSyncOffset(c, slave, offset)
resp := s.doCmd(c, slave.Port(), "GET", "a")
c.Assert(slave.SyncOffset(c), Not(Equals), int64(-1))
c.Assert(resp, DeepEquals, redis.NewBulkBytesWithString("100"))
// write to a slave, must error
resp = s.doCmd(c, slave.Port(), "SET", "e", "1")
c.Assert(resp, FitsTypeOf, (*redis.Error)(nil))
c.Assert(resp.(*redis.Error).Value, Matches, "READONLY.*")
s.doCmdMustOK(c, master.Port(), "SET", "b", "100")
time.Sleep(500 * time.Millisecond)
resp = s.doCmd(c, slave.Port(), "GET", "b")
c.Assert(resp, DeepEquals, redis.NewBulkBytesWithString("100"))
s.doCmdMustOK(c, master.Port(), "SET", "c", "")
// set another value with TTL
s.doCmdMustOK(c, master.Port(), "SET", "ttl_key", "1", "PX", 100)
time.Sleep(500 * time.Millisecond)
resp = s.doCmd(c, slave.Port(), "GET", "c")
c.Assert(resp, DeepEquals, redis.NewBulkBytesWithString(""))
// get expired key to let master force delete it
resp = s.doCmd(c, master.Port(), "GET", "ttl_key")
c.Assert(resp, DeepEquals, redis.NewBulkBytes(nil))
time.Sleep(500 * time.Millisecond)
// the key must be deleted from master repliction
resp = s.doCmd(c, slave.Port(), "GET", "ttl_key")
c.Assert(resp, DeepEquals, redis.NewBulkBytes(nil))
offset = slave.SyncOffset(c)
// now close replication connection
nc.Close(c)
s.doCmdMustOK(c, master.Port(), "SET", "b", "1000")
s.doCmdMustOK(c, master.Port(), "SET", "c", "123")
s.waitAndCheckSyncOffset(c, slave, offset)
resp = s.doCmd(c, slave.Port(), "GET", "b")
c.Assert(resp, DeepEquals, redis.NewBulkBytesWithString("1000"))
resp = s.doCmd(c, slave.Port(), "GET", "c")
c.Assert(resp, DeepEquals, redis.NewBulkBytesWithString("123"))
s.checkRole(c, master.Port(), "master")
s.checkRole(c, slave.Port(), "slave")
s.doCmdMustOK(c, slave.Port(), "SLAVEOF", "NO", "ONE")
s.doCmdMustOK(c, master.Port(), "SLAVEOF", "NO", "ONE")
s.checkRole(c, master.Port(), "master")
s.checkRole(c, slave.Port(), "master")
}
开发者ID:CowLeo,项目名称:qdb,代码行数:72,代码来源:repl_test.go
注:本文中的github.com/reborndb/go/redis/resp.NewBulkBytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论