dtb81443 2018-01-22 08:35
浏览 610
已采纳

获取redis golang的队列长度

I am using go-redis package. I fired below query:

rd.LLen("queue_1")

Which returning me below result with type *redis.IntCmd:

llen queue_1: 100001

Count is perfect but I want only count with type of int. Can anyone help?

  • 写回答

3条回答 默认 最新

  • doushi3189 2018-01-22 08:39
    关注

    the LLen func looks like: func (c *cmdable) LLen(key string) *IntCmd

    So it returns an IntCmd type. IntCmd provides this function: func (cmd *IntCmd) Val() int64

    So you can do e.g.

    cmd := rd.LLen("queue_1")
    i := cmd.Val() //i will be an int64 type
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile