Properly invalidate account caches when unlinking
This commit is contained in:
parent
de427d8bfe
commit
026932049a
@ -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)
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user