Commit a3889cd
fix: make UserRistrettoCache a singleton so all callers share one cache
The root cause of the test failure: UserRistrettoCache() created a new
ristretto cache on every call. The auth middleware and the RotateAPIKey
handler received separate cache instances, so cache.Del() in the
handler had no effect on the middleware's cache — the old key kept
authenticating.
Fix: store the cache as a field on the Container struct and return it
on subsequent calls (lazy singleton pattern), matching how db, app,
and eventDispatcher are already handled.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent d77b99c commit a3889cd
2 files changed
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
1730 | 1731 | | |
1731 | 1732 | | |
1732 | 1733 | | |
1733 | | - | |
1734 | | - | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
1735 | 1739 | | |
1736 | 1740 | | |
1737 | 1741 | | |
| |||
1740 | 1744 | | |
1741 | 1745 | | |
1742 | 1746 | | |
| 1747 | + | |
1743 | 1748 | | |
1744 | 1749 | | |
1745 | 1750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 87 | + | |
| 88 | + | |
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
| |||
0 commit comments