TokenCache.add calls .modify inefficiently
TokenCache.__add pulls cacheable items from the given event and calls modify individually for each item. A single call to TokenCache.add may therefore entail up to 5 modify calls. This can degrade performance for subclasses of TokenCache, in particular PersistedTokenCache, whose modify method acquires a file lock. Handling a single response from AAD can therefore require acquiring this lock up to 5 times.
(I opened this here rather than in the msal-extensions repo because I expect TokenCache subclasses typically want to inherit TokenCache.add)
Such observation is valid. We could use some improvement here. Lucky that, in the expected calling pattern, acquire_token_silent(...) would typically hit a token from cache, so the expensive TokenCache.add() would not be called more often than once an hour.
Marking this as an enhancement here. The actual change may still go into the extensions repo, though.