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

Method getFromCache

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

* 从缓存获取查询结果

(cacheKey: string)

Source from the content-addressed store, hash-verified

655 * 从缓存获取查询结果
656 */
657 private getFromCache(cacheKey: string): readonly Entity[] | null {
658 const entry = this._queryCache.get(cacheKey);
659 if (!entry) return null;
660
661 // 检查缓存是否过期或版本过期
662 if (Date.now() - entry.timestamp > this._cacheTimeout || entry.version !== this._version) {
663 this._queryCache.delete(cacheKey);
664 return null;
665 }
666
667 entry.hitCount++;
668 return entry.entities;
669 }
670
671 /**
672 * 添加查询结果到缓存

Callers 3

queryByTagMethod · 0.95
queryByNameMethod · 0.95
queryByComponentMethod · 0.95

Calls 3

nowMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected