fix: bump pcat cache prefix to invalidate stale empty results
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled
Old queries cached empty arrays for groups and schemas. Bumping cache key prefix from "pcat:" to "pcat2:" so new correct queries bypass stale entries without needing manual Redis flush. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,8 @@ export interface PcatSchemaDetailDto {
|
||||
hotspots: { id: string; key: string; group: number; shape: "rect"; coordinates: number[]; label: string }[];
|
||||
}
|
||||
|
||||
const CACHE_PREFIX = "pcat2"; // bumped to invalidate stale cache from v1 queries
|
||||
|
||||
const CACHE_TTL = {
|
||||
catalogs: 86400,
|
||||
models: 43200,
|
||||
@@ -81,7 +83,7 @@ export class PcatCatalogService {
|
||||
) {}
|
||||
|
||||
async getCatalogs(): Promise<PcatCatalogDto[]> {
|
||||
const cacheKey = "pcat:catalogs";
|
||||
const cacheKey = `${CACHE_PREFIX}:catalogs`;
|
||||
const cached = await this.redis.getJson<PcatCatalogDto[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -108,7 +110,7 @@ export class PcatCatalogService {
|
||||
}
|
||||
|
||||
async getModels(catalogId: string): Promise<PcatModelDto[]> {
|
||||
const cacheKey = `pcat:models:${catalogId}`;
|
||||
const cacheKey = `${CACHE_PREFIX}:models:${catalogId}`;
|
||||
const cached = await this.redis.getJson<PcatModelDto[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -139,7 +141,7 @@ export class PcatCatalogService {
|
||||
}
|
||||
|
||||
async getCars(modelId: string): Promise<PcatCarDto[]> {
|
||||
const cacheKey = `pcat:cars:${modelId}`;
|
||||
const cacheKey = `${CACHE_PREFIX}:cars:${modelId}`;
|
||||
const cached = await this.redis.getJson<PcatCarDto[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -184,7 +186,7 @@ export class PcatCatalogService {
|
||||
}
|
||||
|
||||
async getCarGroups(carId: string, parentId?: string): Promise<PcatGroupDto[]> {
|
||||
const cacheKey = `pcat:car-groups:${carId}:${parentId || "root"}`;
|
||||
const cacheKey = `${CACHE_PREFIX}:car-groups:${carId}:${parentId || "root"}`;
|
||||
const cached = await this.redis.getJson<PcatGroupDto[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -233,7 +235,7 @@ export class PcatCatalogService {
|
||||
}
|
||||
|
||||
async getSchemaImages(carId: string, groupId: string): Promise<PcatSchemaImageDto[]> {
|
||||
const cacheKey = `pcat:schemas:${carId}:${groupId}`;
|
||||
const cacheKey = `${CACHE_PREFIX}:schemas:${carId}:${groupId}`;
|
||||
const cached = await this.redis.getJson<PcatSchemaImageDto[]>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
@@ -257,7 +259,7 @@ export class PcatCatalogService {
|
||||
}
|
||||
|
||||
async getSchemaDetail(schemaImageId: string): Promise<PcatSchemaDetailDto> {
|
||||
const cacheKey = `pcat:schema-detail:${schemaImageId}`;
|
||||
const cacheKey = `${CACHE_PREFIX}:schema-detail:${schemaImageId}`;
|
||||
const cached = await this.redis.getJson<PcatSchemaDetailDto>(cacheKey);
|
||||
if (cached) return cached;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user