Cache optimization with automatic expiration: 1. New Cache Structure: - Changed from simple array to TTL-aware structure - Each entry: ['data' => ..., 'expires' => timestamp] - 5-minute (300s) TTL prevents indefinite stale data 2. Helper Methods: - getCached($key): Returns data if not expired, null otherwise - setCached($key, $data): Stores with expiration timestamp - invalidateCache($userId, $username): Manual cache clearing 3. Updated All Cache Access Points: - syncUserFromAuthelia() - User sync from Authelia - getSystemUser() - System user for daemon operations - getUserById() - User lookup by ID - getUserByUsername() - User lookup by username Benefits: - Prevents memory leaks from unlimited cache growth - Ensures user data refreshes periodically - Maintains performance benefits of caching - Automatic cleanup of expired entries Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
7.9 KiB
7.9 KiB