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,33 @@
# @RedisHash(timeToLive = 2) with enableKeyspaceEvents = ON_STARTUP
--- Server setting before the application context started ---
$ redis-cli -p 6390 --no-raw CONFIG GET notify-keyspace-events
1) "notify-keyspace-events"
2) ""
--- Server setting now ---
$ redis-cli -p 6390 --no-raw CONFIG GET notify-keyspace-events
1) "notify-keyspace-events"
2) "xE"
--- Save a session that lives for two seconds ---
sessions.save(new Session("s1", "ankur"))
$ redis-cli -p 6390 KEYS '*' | sort
session
session:s1
session:s1:idx
session:s1:phantom
session:user:ankur
$ redis-cli -p 6390 --no-raw TTL session:s1
(integer) 2
$ redis-cli -p 6390 --no-raw TTL session:s1:phantom
(integer) 302
--- Wait for Redis to expire it, and for Spring to react ---
RedisKeyExpiredEvent: keyspace=session id=s1 value=Session[id=s1, user=ankur]
--- What is left behind ---
$ redis-cli -p 6390 --no-raw DBSIZE
(integer) 0
sessions.count() = 0