Q11 Redis Domain 2 · 25–30% of exam

A session store uses Redis. Each session should expire 30 minutes after the last user activity. Which TTL approach implements this?

  1. A Set TTL once at creation
  2. B Use EXPIRE key 1800 on every read/write to reset the idle timeout (correct answer)
  3. C Use a sorted set with timestamps
  4. D Use keyspace notifications to detect access

Shortcut: Resetting the TTL (EXPIRE key 1800) on every access implements a sliding expiration. If no activity occurs for 30 minutes, the key naturally expires and the session ends.