# @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