Properly invalidate account caches when unlinking

This commit is contained in:
Ske 2020-02-03 15:04:53 +01:00
parent de427d8bfe
commit 026932049a
2 changed files with 8 additions and 2 deletions

View File

@ -27,14 +27,19 @@ namespace PluralKit.Core
public Task InvalidateSystem(PKSystem system) => InvalidateSystem(system.Id);
public void InvalidateAccounts(IEnumerable<ulong> accounts)
{
foreach (var account in accounts)
_cache.Remove(KeyForAccount(account));
}
public void InvalidateDeletedSystem(int systemId, IEnumerable<ulong> accounts)
{
// Used when the system's already removed so we can't look up accounts
// We assume the account list is saved already somewhere and can be passed here (which is the case in Store)
_cache.Remove(KeyForSystem(systemId));
foreach (var account in accounts)
_cache.Remove(KeyForAccount(account));
InvalidateAccounts(accounts);
}
public async Task InvalidateSystem(int systemId)

View File

@ -509,6 +509,7 @@ namespace PluralKit {
_logger.Information("Unlinked system {System} from account {Account}", system.Id, accountId);
await _cache.InvalidateSystem(system);
_cache.InvalidateAccounts(new [] { accountId });
}
public async Task<PKSystem> GetSystemByAccount(ulong accountId) {