Caused by: io.lettuce.core.RedisException: java.lang.IllegalStateException

记录一个redis使用过程中出现的一个异常

org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.lang.IllegalStateException
原因是:在使用lua脚本完成redis的获取token与删除token,使其为一个原子操作
String script = "if redis.call('get',KEYS[1]) == ARGV[1] then return redis.call('del',KEYS[1]) else return 0 end";
Long executeResult = stringRedisTemplate.execute(new DefaultRedisScript<>(script, Long.class),…)
接收的返回值应该是Long类型的,我原来写成Integer类型,所以报了这个错。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐