perf(public): 公开读路径进程内分域缓存——meta/goods/matrix 版本域 + TTL 兜底 + in-flight 合并
- PublicCacheService:分域版本号失效(bump 即作废,不等 TTL)、loader 期间 bump 的竞态防护(返回但不回写)、并发 miss 单飞、PUBLIC_CACHE_DISABLED /TTL_MS/MAX_ENTRIES 应急开关;@Global 模块 - PublicService 六端点接缓存:列表缓存全量物化(分页切片在缓存外按请求执行, 修复'所有页返回第一页'的切片缓存错误)、详情/首页/树/标签组/树序元数据/ 族最低价聚合各按依赖域缓存 - 全写路径挂钩 bump:admin CRUD(goods/categories/countries/tags/tag-groups/ positions/origin-goods 标签)、sync 三同步、族重算、整理全家桶—— 事务提交成功后失效对应域,product-families 经 recompute 天然覆盖 - 测试:PublicCacheService 单测 13 例 + 失效链路集成 8 例(读命中/写后立即可见 端到端/每条写路径域断言);既有两套件测数据语义改为显式禁缓存
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* 后台等价入口:POST /product-families/organize(「整理」按钮)。
|
||||
*/
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { PublicCacheService } from '../src/public/public-cache.service';
|
||||
import { FamilyRecomputeService } from '../src/product-families/family-recompute.service';
|
||||
import { ProductFamiliesService } from '../src/product-families/product-families.service';
|
||||
import { OrganizeService } from '../src/product-families/organize.service';
|
||||
@@ -16,9 +17,9 @@ import { OrganizeService } from '../src/product-families/organize.service';
|
||||
async function main() {
|
||||
const prisma = new PrismaService();
|
||||
await prisma.onModuleInit();
|
||||
const recompute = new FamilyRecomputeService(prisma);
|
||||
const recompute = new FamilyRecomputeService(prisma, new PublicCacheService());
|
||||
const families = new ProductFamiliesService(prisma, recompute);
|
||||
const organize = new OrganizeService(prisma, recompute, families);
|
||||
const organize = new OrganizeService(prisma, recompute, families, new PublicCacheService());
|
||||
|
||||
const result = await organize.organize();
|
||||
console.log(
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* origin_goods.good_name 为 SDS 纯镜像(每小时同步覆盖),本脚本只改 goods.good_name。
|
||||
*/
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { PublicCacheService } from '../src/public/public-cache.service';
|
||||
import { SyncService } from '../src/sync/sync.service';
|
||||
import { FamilyRecomputeService } from '../src/product-families/family-recompute.service';
|
||||
import { GoodsService } from '../src/goods/goods.service';
|
||||
@@ -16,12 +17,13 @@ async function main() {
|
||||
const dryRun = !process.argv.includes('--apply');
|
||||
const prisma = new PrismaService();
|
||||
await prisma.onModuleInit();
|
||||
const recompute = new FamilyRecomputeService(prisma);
|
||||
const recompute = new FamilyRecomputeService(prisma, new PublicCacheService());
|
||||
// 回填路径不触发详情同步,SyncService 仅作占位依赖
|
||||
const goods = new GoodsService(
|
||||
prisma,
|
||||
{ queueProductDetailSync: async () => undefined } as unknown as SyncService,
|
||||
recompute,
|
||||
new PublicCacheService(),
|
||||
);
|
||||
|
||||
const result = await goods.backfillPureSkuGoodNames({ dryRun });
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
* 运行:pnpm --filter @inkreach/api recompute:families
|
||||
*/
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { PublicCacheService } from '../src/public/public-cache.service';
|
||||
import { FamilyRecomputeService } from '../src/product-families/family-recompute.service';
|
||||
|
||||
async function main() {
|
||||
const prisma = new PrismaService();
|
||||
await prisma.onModuleInit();
|
||||
const recompute = new FamilyRecomputeService(prisma);
|
||||
const recompute = new FamilyRecomputeService(prisma, new PublicCacheService());
|
||||
|
||||
const families = await prisma.productFamily.findMany({
|
||||
select: { id: true },
|
||||
|
||||
Reference in New Issue
Block a user