RedisCommandExecutionException: @user_script: 24: Lua redis() command arguments must be strings or i

11 篇文章 0 订阅
4 篇文章 0 订阅

序言

在完成redis的测试后,之前看到了阿里巴巴的开发手册,今天又看了一下,于是对照了自己的代码,发现了一个地方需要修改
在这里插入图片描述

过程

就是我用了Arrays.asList()的方法,而且我里面放的不是数组,就是一个个的字符串

  List<String> busilist = Arrays.asList(sNNameValue,increAmountValue,seq);

于是想在既然如此,我把读取到的这三个值直接放到ArrayList里面就可以,但是lua脚本执行的时候却报错了

[2020-06-09 16:41:17,898]-[ERROR]-[http-nio-8085-exec-1]-[redis.service.RedisServiceImpl:63]-cannot get seq from redis cluster ,please check redis cluster_Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: @user_script: 24: Lua redis() command arguments must be strings or integers
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: @user_script: 24: Lua redis() command arguments must be strings or integers
	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:54) ~[spring-data-redis-2.2.6.RELEASE.jar:2.2.6.RELEASE]
	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:52) ~[spring-data-redis-2.2.6.RELEASE.jar:2.2.6.RELEASE]

由此可见,肯定是传到lua脚本里的值对不上了,于是看了我的lua脚本里的第24行

 local nextSeq = redis.call('incrby', key, incr_amoutt)

而incr_amoutt来自于脚本的开始时获取的值,这个值本应该是number,而我传了一个别的类型的,就报这个错了。

    local incr_amoutt = tonumber(KEYS[2])

于是看了我传过去的list值,打印日志发现:

[2020-06-09 16:58:10,849]-[INFO]-[http-nio-8085-exec-1]-[redis.service.RedisServiceImpl:59]-busilist:1000
[2020-06-09 16:58:10,850]-[INFO]-[http-nio-8085-exec-1]-[redis.service.RedisServiceImpl:59]-busilist:SEQUENCE_MCAS_FILEGEN_FHF_SERVICENUMBER
[2020-06-09 16:58:10,850]-[INFO]-[http-nio-8085-exec-1]-[ai.nrjf.service.RedisServiceImpl:59]-busilist:0

list里面的第二个值是key的字符串值,肯定无法转为number,必然报错,于是就修改为:

解决办法

List<String> busilist = new ArrayList<>(Arrays.asList(sNNameValue,increAmountValue,seq));

这样值的顺序就不会乱了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值