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 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)
|
public void InvalidateDeletedSystem(int systemId, IEnumerable<ulong> accounts)
|
||||||
{
|
{
|
||||||
// Used when the system's already removed so we can't look up 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)
|
// We assume the account list is saved already somewhere and can be passed here (which is the case in Store)
|
||||||
|
|
||||||
_cache.Remove(KeyForSystem(systemId));
|
_cache.Remove(KeyForSystem(systemId));
|
||||||
foreach (var account in accounts)
|
InvalidateAccounts(accounts);
|
||||||
_cache.Remove(KeyForAccount(account));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InvalidateSystem(int systemId)
|
public async Task InvalidateSystem(int systemId)
|
||||||
|
@ -509,6 +509,7 @@ namespace PluralKit {
|
|||||||
|
|
||||||
_logger.Information("Unlinked system {System} from account {Account}", system.Id, accountId);
|
_logger.Information("Unlinked system {System} from account {Account}", system.Id, accountId);
|
||||||
await _cache.InvalidateSystem(system);
|
await _cache.InvalidateSystem(system);
|
||||||
|
_cache.InvalidateAccounts(new [] { accountId });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PKSystem> GetSystemByAccount(ulong accountId) {
|
public async Task<PKSystem> GetSystemByAccount(ulong accountId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user