Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
17 lines
960 B
Plaintext
17 lines
960 B
Plaintext
# 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]
|