Add redis: Boot 4.1 + Spring Data Redis 4.1, the JDK-serialisation default vs Jackson 3 serializers, @RedisHash TTL and keyspace events, @RedisListener, and Redis as the Spring cache

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
Claude
2026-09-21 15:46:55 +00:00
parent 8cdfcd4d8d
commit b0c39a8d4c
60 changed files with 2900 additions and 1 deletions
@@ -0,0 +1,16 @@
# The default template refuses a value that is not java.io.Serializable
--- A record that does not implement Serializable ---
redisTemplate.opsForValue().set("user:2", new User(2, "Ankur"))
org.springframework.data.redis.serializer.SerializationException
message: Cannot serialize
cause: Failed to serialize object using DefaultSerializer
root: DefaultSerializer requires a Serializable payload but received an object of type [com.ankurm.redis.model.User]
keys afterwards: 0
--- The same shape, implementing Serializable ---
redisTemplate.opsForValue().set("user:3", new SerializableUser(3, "Ankur"))
$ redis-cli -p 6390 --no-raw EVAL 'return redis.call("GET", redis.call("KEYS", "*")[1])' 0
"\xac\xed\x00\x05sr\x00'com.ankurm.redis.model.SerializableUser\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02J\x00\x02idL\x00\x04namet\x00\x12Ljava/lang/String;xp\x00\x00\x00\x00\x00\x00\x00\x03t\x00\x05Ankur"
read back: SerializableUser[id=3, name=Ankur]