本文整理汇总了Golang中github.com/siddontang/ledisdb/ledis.StrInt64函数的典型用法代码示例。如果您正苦于以下问题:Golang StrInt64函数的具体用法?Golang StrInt64怎么用?Golang StrInt64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrInt64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: lrangeCommand
func lrangeCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
var start int64
var stop int64
var err error
start, err = ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
stop, err = ledis.StrInt64(args[2], nil)
if err != nil {
return err
}
if v, err := c.db.LRange(args[0], int32(start), int32(stop)); err != nil {
return err
} else {
c.writeArray(v)
}
return nil
}
开发者ID:rchunping,项目名称:ledisdb,代码行数:28,代码来源:cmd_list.go
示例2: lrangeCommand
func lrangeCommand(req *requestContext) error {
args := req.args
if len(args) != 3 {
return ErrCmdParams
}
var start int64
var stop int64
var err error
start, err = ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
stop, err = ledis.StrInt64(args[2], nil)
if err != nil {
return ErrValue
}
if v, err := req.db.LRange(args[0], int32(start), int32(stop)); err != nil {
return err
} else {
req.resp.writeSliceArray(v)
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:28,代码来源:cmd_list.go
示例3: lTrimCommand
func lTrimCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
var start int64
var stop int64
var err error
start, err = ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
stop, err = ledis.StrInt64(args[2], nil)
if err != nil {
return ErrValue
}
if err := c.db.LTrim(args[0], start, stop); err != nil {
return err
} else {
c.resp.writeStatus(OK)
}
return nil
}
开发者ID:Aurlin,项目名称:ledisdb,代码行数:27,代码来源:cmd_list.go
示例4: syncCommand
func syncCommand(req *requestContext) error {
args := req.args
if len(args) != 2 {
return ErrCmdParams
}
var logIndex int64
var logPos int64
var err error
logIndex, err = ledis.StrInt64(args[0], nil)
if err != nil {
return ErrCmdParams
}
logPos, err = ledis.StrInt64(args[1], nil)
if err != nil {
return ErrCmdParams
}
req.syncBuf.Reset()
//reserve space to write master info
if _, err := req.syncBuf.Write(reserveInfoSpace); err != nil {
return err
}
m := &ledis.MasterInfo{logIndex, logPos}
if _, err := req.app.ldb.ReadEventsTo(m, &req.syncBuf); err != nil {
return err
} else {
buf := req.syncBuf.Bytes()
binary.BigEndian.PutUint64(buf[0:], uint64(m.LogFileIndex))
binary.BigEndian.PutUint64(buf[8:], uint64(m.LogPos))
if len(req.compressBuf) < snappy.MaxEncodedLen(len(buf)) {
req.compressBuf = make([]byte, snappy.MaxEncodedLen(len(buf)))
}
if buf, err = snappy.Encode(req.compressBuf, buf); err != nil {
return err
}
req.resp.writeBulk(buf)
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:49,代码来源:cmd_replication.go
示例5: syncCommand
func syncCommand(c *client) error {
args := c.args
if len(args) != 2 {
return ErrCmdParams
}
var logIndex int64
var logPos int64
var err error
logIndex, err = ledis.StrInt64(args[0], nil)
if err != nil {
return ErrCmdParams
}
logPos, err = ledis.StrInt64(args[1], nil)
if err != nil {
return ErrCmdParams
}
c.syncBuf.Reset()
//reserve space to write binlog anchor
if _, err := c.syncBuf.Write(reserveInfoSpace); err != nil {
return err
}
m := &ledis.BinLogAnchor{logIndex, logPos}
if _, err := c.app.ldb.ReadEventsToTimeout(m, &c.syncBuf, 5); err != nil {
return err
} else {
buf := c.syncBuf.Bytes()
binary.BigEndian.PutUint64(buf[0:], uint64(m.LogFileIndex))
binary.BigEndian.PutUint64(buf[8:], uint64(m.LogPos))
if len(c.compressBuf) < snappy.MaxEncodedLen(len(buf)) {
c.compressBuf = make([]byte, snappy.MaxEncodedLen(len(buf)))
}
if buf, err = snappy.Encode(c.compressBuf, buf); err != nil {
return err
}
c.resp.writeBulk(buf)
}
return nil
}
开发者ID:Abioy,项目名称:ledisdb,代码行数:49,代码来源:cmd_replication.go
示例6: zaddCommand
func zaddCommand(c *client) error {
args := c.args
if len(args) < 3 {
return ErrCmdParams
}
key := args[0]
if len(args[1:])%2 != 0 {
return ErrCmdParams
}
args = args[1:]
params := make([]ledis.ScorePair, len(args)/2)
for i := 0; i < len(params); i++ {
score, err := ledis.StrInt64(args[2*i], nil)
if err != nil {
return err
}
params[i].Score = score
params[i].Member = args[2*i+1]
}
if n, err := c.db.ZAdd(key, params...); err != nil {
return err
} else {
c.writeInteger(n)
}
return nil
}
开发者ID:Gohan,项目名称:ledisdb,代码行数:32,代码来源:cmd_zset.go
示例7: zexpireAtCommand
func zexpireAtCommand(req *requestContext) error {
args := req.args
if len(args) != 2 {
return ErrCmdParams
}
when, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if v, err := req.db.ZExpireAt(args[0], when); err != nil {
return err
} else {
req.resp.writeInteger(v)
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:18,代码来源:cmd_zset.go
示例8: lindexCommand
func lindexCommand(req *requestContext) error {
args := req.args
if len(args) != 2 {
return ErrCmdParams
}
index, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if v, err := req.db.LIndex(args[0], int32(index)); err != nil {
return err
} else {
req.resp.writeBulk(v)
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:19,代码来源:cmd_list.go
示例9: decrbyCommand
func decrbyCommand(req *requestContext) error {
args := req.args
if len(args) != 2 {
return ErrCmdParams
}
delta, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if n, err := req.db.DecrBy(req.args[0], delta); err != nil {
return err
} else {
req.resp.writeInteger(n)
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:19,代码来源:cmd_kv.go
示例10: setexCommand
func setexCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
sec, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if err := c.db.SetEX(args[0], sec, args[2]); err != nil {
return err
} else {
c.resp.writeStatus(OK)
}
return nil
}
开发者ID:Aurlin,项目名称:ledisdb,代码行数:19,代码来源:cmd_kv.go
示例11: decrbyCommand
func decrbyCommand(c *client) error {
args := c.args
if len(args) != 2 {
return ErrCmdParams
}
delta, err := ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
if n, err := c.db.DecrBy(c.args[0], delta); err != nil {
return err
} else {
c.writeInteger(n)
}
return nil
}
开发者ID:rchunping,项目名称:ledisdb,代码行数:19,代码来源:cmd_kv.go
示例12: zexpireAtCommand
func zexpireAtCommand(c *client) error {
args := c.args
if len(args) != 2 {
return ErrCmdParams
}
when, err := ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
if v, err := c.db.ZExpireAt(args[0], when); err != nil {
return err
} else {
c.writeInteger(v)
}
return nil
}
开发者ID:Gohan,项目名称:ledisdb,代码行数:19,代码来源:cmd_zset.go
示例13: hexpireCommand
func hexpireCommand(c *client) error {
args := c.args
if len(args) != 2 {
return ErrCmdParams
}
duration, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if v, err := c.db.HExpire(args[0], duration); err != nil {
return err
} else {
c.resp.writeInteger(v)
}
return nil
}
开发者ID:Abioy,项目名称:ledisdb,代码行数:19,代码来源:cmd_hash.go
示例14: hincrbyCommand
func hincrbyCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
delta, err := ledis.StrInt64(args[2], nil)
if err != nil {
return ErrValue
}
var n int64
if n, err = c.db.HIncrBy(args[0], args[1], delta); err != nil {
return err
} else {
c.resp.writeInteger(n)
}
return nil
}
开发者ID:Abioy,项目名称:ledisdb,代码行数:19,代码来源:cmd_hash.go
示例15: lindexCommand
func lindexCommand(c *client) error {
args := c.args
if len(args) != 2 {
return ErrCmdParams
}
index, err := ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
if v, err := c.db.LIndex(args[0], int32(index)); err != nil {
return err
} else {
c.writeBulk(v)
}
return nil
}
开发者ID:rchunping,项目名称:ledisdb,代码行数:19,代码来源:cmd_list.go
示例16: zincrbyCommand
func zincrbyCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
key := args[0]
delta, err := ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
if v, err := c.db.ZIncrBy(key, delta, args[2]); err != nil {
return err
} else {
c.writeBulk(ledis.StrPutInt64(v))
}
return nil
}
开发者ID:Gohan,项目名称:ledisdb,代码行数:21,代码来源:cmd_zset.go
示例17: restoreCommand
// unlike redis, restore will try to delete old key first
func restoreCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
key := args[0]
ttl, err := ledis.StrInt64(args[1], nil)
if err != nil {
return err
}
data := args[2]
if err = c.db.Restore(key, ttl, data); err != nil {
return err
} else {
c.resp.writeStatus(OK)
}
return nil
}
开发者ID:BobbWu,项目名称:ledisdb,代码行数:22,代码来源:cmd_migrate.go
示例18: zincrbyCommand
func zincrbyCommand(c *client) error {
args := c.args
if len(args) != 3 {
return ErrCmdParams
}
key := args[0]
delta, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
v, err := c.db.ZIncrBy(key, delta, args[2])
if err == nil {
c.resp.writeBulk(num.FormatInt64ToSlice(v))
}
return err
}
开发者ID:BobbWu,项目名称:ledisdb,代码行数:21,代码来源:cmd_zset.go
示例19: zincrbyCommand
func zincrbyCommand(req *requestContext) error {
args := req.args
if len(args) != 3 {
return ErrCmdParams
}
key := args[0]
delta, err := ledis.StrInt64(args[1], nil)
if err != nil {
return ErrValue
}
if v, err := req.db.ZIncrBy(key, delta, args[2]); err != nil {
return err
} else {
req.resp.writeBulk(ledis.StrPutInt64(v))
}
return nil
}
开发者ID:JREAMLU,项目名称:ledisdb,代码行数:21,代码来源:cmd_zset.go
示例20: xrestoreCommand
// maybe only used in xcodis for redis data port
func xrestoreCommand(c *client) error {
args := c.args
if len(args) != 4 {
return ErrCmdParams
}
// tp := strings.ToUpper(string(args[2]))
key := args[1]
ttl, err := ledis.StrInt64(args[2], nil)
if err != nil {
return err
}
data := args[3]
if err = c.db.Restore(key, ttl, data); err != nil {
return err
} else {
c.resp.writeStatus(OK)
}
return nil
}
开发者ID:BobbWu,项目名称:ledisdb,代码行数:23,代码来源:cmd_migrate.go
注:本文中的github.com/siddontang/ledisdb/ledis.StrInt64函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论