Browse Source

Improve caching

pull/3393/head
Thomas Kaul 1 year ago
parent
commit
c4816c809c
  1. 10
      apps/api/src/app/redis-cache/redis-cache.service.ts
  2. 7
      apps/api/src/app/user/user.controller.ts

10
apps/api/src/app/redis-cache/redis-cache.service.ts

@ -26,7 +26,13 @@ export class RedisCacheService {
} }
public async getKeys(aPrefix?: string): Promise<string[]> { public async getKeys(aPrefix?: string): Promise<string[]> {
return this.cache.store.keys(aPrefix); let prefix = aPrefix;
if (prefix) {
prefix = `${prefix}*`;
}
return this.cache.store.keys(prefix);
} }
public getPortfolioSnapshotKey({ public getPortfolioSnapshotKey({
@ -67,7 +73,7 @@ export class RedisCacheService {
); );
for (const key of keys) { for (const key of keys) {
this.remove(key); await this.remove(key);
} }
} }

7
apps/api/src/app/user/user.controller.ts

@ -144,10 +144,7 @@ export class UserController {
); );
} }
const haveFiltersChanged = const emitPortfolioChangedEvent = 'baseCurrency' in data;
'filters.accounts' in data ||
'filters.assetClasses' in data ||
'filters.tags' in data;
const userSettings: UserSettings = merge( const userSettings: UserSettings = merge(
{}, {},
@ -162,8 +159,8 @@ export class UserController {
} }
return this.userService.updateUserSetting({ return this.userService.updateUserSetting({
emitPortfolioChangedEvent,
userSettings, userSettings,
emitPortfolioChangedEvent: haveFiltersChanged,
userId: this.request.user.id userId: this.request.user.id
}); });
} }

Loading…
Cancel
Save