Tag Archives: RedisTemplate increment Error

[Solved] RedisTemplate increment Error: io.lettuce.core.RedisCommandExecutionException: ERR value is not an intege

Redistemplate uses increment to report an error: io.lettuce.core.RedisCommandExecutionException: ERR value is not an intege

Problem analysis

We can learn from spring’s documents that spring has two rare serialization strategies for redis. One is the JDKSerializationRedisSerialzer serialization of RedisTemplate application. The serialized value contains object information, version number, class information, etc. after this serialization, a string cannot be self incremented.

The other is the StringRedisSerializer adopted by the StringRedisTemplate. This strategy converts the string value into a byte array, so the values saved in redis can be operated.

Solution:

Replace RedisTemplate with String RedisTemplate