* 添加查询结果到缓存
(cacheKey: string, entities: Entity[])
| 672 | * 添加查询结果到缓存 |
| 673 | */ |
| 674 | private addToCache(cacheKey: string, entities: Entity[]): void { |
| 675 | // 如果缓存已满,清理最少使用的条目 |
| 676 | if (this._queryCache.size >= this._cacheMaxSize) { |
| 677 | this.cleanupCache(); |
| 678 | } |
| 679 | |
| 680 | this._queryCache.set(cacheKey, { |
| 681 | entities: entities, // 直接使用引用,通过版本号控制失效 |
| 682 | timestamp: Date.now(), |
| 683 | hitCount: 0, |
| 684 | version: this._version |
| 685 | }); |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * 清理缓存 |
no test coverage detected