perf: 공유 지도와 토너먼트 revision을 원자화

지도 캐시는 coverage가 확인된 PostgreSQL map.world head만 사용하고 실패 시 전체 계산으로 복구한다. 토너먼트 Redis payload와 source revision은 Lua 한 번으로 갱신한다.
This commit is contained in:
2026-08-16 18:37:48 +00:00
parent 7e099326ec
commit e4ac2a60b1
13 changed files with 482 additions and 55 deletions
@@ -26,6 +26,20 @@ class MemoryRedis {
this.store.set(key, value);
return 'OK';
}
async eval(_script: string, options: { keys: string[]; arguments: string[] }): Promise<string> {
const [valueKey, revisionKey] = options.keys;
const [value] = options.arguments;
if (!valueKey || !revisionKey || value === undefined) throw new Error('invalid eval arguments');
const revision = Number(this.store.get(revisionKey) ?? '0') + 1;
this.store.set(valueKey, value);
this.store.set(revisionKey, String(revision));
return String(revision);
}
async publish(): Promise<number> {
return 0;
}
}
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null;