attempt to compare two nil values问题解决
主要是因为redis lua 只支持json 格式保存 如果lua里面用到的是key value,就设置setValueSerializer,
如果lua里面用到的是hash,就设置setHashValueSerializer, 总之用到哪些就需要设置哪些
切记设置完之后原来的数据都删掉,用新的格式保存一下才可以
参考配置如下
@Bean public RedisTemplate<String, Object> redisTemplate(@Qualifier("lettuceConnectionFactory")LettuceConnectionFactory lettuceConnectionFactory) { Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer()); redisTemplate.setConnectionFactory(lettuceConnectionFactory); return redisTemplate; }
java.lang.IllegalStateException问题解决
主要是因为lua 不支持integer 类型,切换成long.class即可
参考代码