Use catalog: prefix for catalog entity cache

Signed-off-by: Joe Porpeglia <josephp@spotify.com>
This commit is contained in:
Joe Porpeglia
2022-01-10 16:47:22 -05:00
committed by Joe Porpeglia
parent 413c9fab08
commit c2f54048d1
2 changed files with 8 additions and 8 deletions
@@ -80,7 +80,7 @@ describe('CachedEntityLoader', () => {
expect(result).toEqual(entity);
expect(cache.set).toBeCalledWith(
'component:default/test:user:default/test-user',
'catalog:component:default/test:user:default/test-user',
entity,
{ ttl: 5000 },
);
@@ -126,7 +126,7 @@ describe('CachedEntityLoader', () => {
const result = await loader.load(entityName, undefined);
expect(result).toEqual(entity);
expect(cache.set).toBeCalledWith('component:default/test', entity, {
expect(cache.set).toBeCalledWith('catalog:component:default/test', entity, {
ttl: 5000,
});
});
@@ -82,14 +82,14 @@ export class CachedEntityLoader {
entityName: EntityName,
token: string | undefined,
): Promise<string> {
const entityRef = stringifyEntityRef(entityName);
const key = ['catalog'];
key.push(stringifyEntityRef(entityName));
if (!token) {
return entityRef;
if (token) {
const response = await this.identity.authenticate(token);
key.push(response.identity.userEntityRef);
}
const response = await this.identity.authenticate(token);
return `${entityRef}:${response.identity.userEntityRef}`;
return key.join(':');
}
}