Skip to content

Commit

Permalink
adjust roles cache to use different tokens for different operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Metauriel committed Nov 5, 2024
1 parent b290804 commit 6dec922
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('School Controller (API)', () => {

beforeEach(async () => {
await cleanupCollections(em);
await em.clearCache('roles-cache-teacher');
await em.clearCache('roles-cache-byname-teacher');
await em.clearCache('bymultiplenames-byname-teacher');
});

afterAll(async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/shared/repo/role/role.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class RoleRepo extends BaseRepo<Role> {
const promise: Promise<Role> = this._em.findOneOrFail(
Role,
{ name },
{ cache: [`roles-cache-${name}`, this.cacheExpiration] }
{ cache: [`roles-cache-bymultiplenames-${name}`, this.cacheExpiration] }
);
return promise;
}
Expand All @@ -30,7 +30,7 @@ export class RoleRepo extends BaseRepo<Role> {
const promise: Promise<Role[]> = this._em.find(
Role,
{ name: { $in: names } },
{ cache: [`roles-cache-${names.join('-')}`, this.cacheExpiration] }
{ cache: [`roles-cache-bymultiplenames-${names.join('-')}`, this.cacheExpiration] }
);
return promise;
}
Expand Down

0 comments on commit 6dec922

Please sign in to comment.