本文整理汇总了Golang中github.com/siddontang/ledisdb/ledis.StrInt64函数的典型用法代码示例。如果您正苦于以下问题:Golang StrInt64函数的具体用法?Golang StrInt64怎么用?Golang StrInt64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrInt64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}