MCPcopy Create free account
hub / github.com/esengine/esengine / addToCache

Method addToCache

packages/core/src/ECS/Core/QuerySystem.ts:674–686  ·  view source on GitHub ↗

* 添加查询结果到缓存

(cacheKey: string, entities: Entity[])

Source from the content-addressed store, hash-verified

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 * 清理缓存

Callers 3

queryByTagMethod · 0.95
queryByNameMethod · 0.95
queryByComponentMethod · 0.95

Calls 3

cleanupCacheMethod · 0.95
nowMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected