Premier League Predictor: FastAPI & Redis — Chapter 9, Exercise 1 ================================================================= TASK Enter one 1-0 result in each of two seasons using team-keyed stats hashes, report team 1's stats, then repeat with season-scoped stats keys and report each season's played count. State what changed in the script (nothing) and what changed in the caller. SOLUTION Team-keyed (KEYS[4] = "team:1:stats", KEYS[5] = "team:2:stats"), one 1-0 result in season 1 and one in season 2: team:1:stats -> {'played': '2', 'gf': '2', 'ga': '0', 'won': '2'} One game was played in each season, but the record shows two games and two wins: season 2's table would start with season 1's record in it. Season-scoped (KEYS[4] = "season:{sid}:team:1:stats", and so on): season 1, team 1 played -> 1 season 2, team 1 played -> 1 What changed: only the key names the route builds and passes in. The script never mentions a season - it operates on whichever five keys it is handed - so it needed no edit. Every key it touches arrives in KEYS, which is what makes that possible. WHY THIS WORKS AS AN ANSWER ---------------------------- It reproduces the carry-over with real output, shows the same script producing correct per-season numbers, and locates the fix in the caller, which is the point of passing keys into a script.