我是靠谱客的博主 专注大地,这篇文章主要介绍RedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException: ERR value is not an integeRedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException: ERR value is not an integer or out of range,现在分享给大家,希望可以做个参考。
RedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException: ERR value is not an integer or out of range
问题分析
我们通过Spring的文档可以得知,Spring对Redis的罕用序列化的策略有两种,一种是RedisTemplate应用的JDKSerializationRedisSerialzer序列化,此序列化后得的值蕴含了对象的信息,版本号,类信息等,此序列化后是一个字符串没无法进行自增等操作。
另一种是StringRedisTemplate采用的StringRedisSerializer,此策略是将字符串的值转为为字节数组,所以保存到redis中的是数值,可以进行操作。
解决方法
把RedisTemplate换成String RedisTemplate
最后
以上就是专注大地最近收集整理的关于RedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException: ERR value is not an integeRedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException: ERR value is not an integer or out of range的全部内容,更多相关RedisTemplate使用increment报错io.lettuce.core.RedisCommandExecutionException:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复