You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever referenceTopic is passed to most ITopicRepository.Load() implementation, it ultimately needs to be indexed via referenceTopic.GetRootTopic().GetTopicIndex(). This requires crawling the entire tree each request. Meanwhile, consumers like the CachedTopicService end up maintaining their own cache. Instead, provide a static reference to a list of TopicIndex instances keyed by their root topic instance.
While this isn't strictly necessary for lazy-loading (#111), it provides an important performance foundation for lazy-loading capabilities, such as dynamically resolving associations and merging ascendants into an existing tree.
Garbage Handling
This will need to use a ConditionalWeakTable<> (CWT) to make sure that this doesn't hold onto e.g., one-time indexes no longer referenced by other code. Otherwise, this could result in a memory leak with every one-off load potentially being held onto indefinitely.
Tasks
TopicIndexRegistry: Concurrency-safe storage, with hooks for attaching, detaching, and assigning IDs, assigned on Parent
Consolidate CachedTopicRepository onto the live index, retiring its redundant _topicIdIndex
Activity
CachedTopicRepository#111Topic.Children#119ITopicRepository.Load()#120Merge pull request #145 from OnTopicCMS/feature/ITopicRepository-lazy…
JeremyCaney commentedon Aug 9, 2026
Merged with cb8e2ca:
TopicIndexRegistry: Concurrency-safe storage, with hooks for attaching, detaching, and assigning IDs, assigned onParentTopicIndexRegistryas a CWT-backed cache, plus its add, remove, and save event handlers (a15ae85) with unit tests (0587bbc)TopicIndextoConcurrentDictionary<>(ffb77d9)TopicIndexRegistry"event" handlers; hooks it intoTopicadd, remove, and save events, includingParentassignment (273beeb)GetLiveTopicIndex()method toTopic(a18d8d5)GetLiveTopicIndex()overGetTopicIndex()(4757d89)AddTopic()(9ef4189) with unit tests (e37be61)GetTopicUpdates, so parents are always indexed before children (0a30ecd) with unit tests (21e5277)CachedTopicRepositoryonto the live index, retiring its redundant_topicIdIndex_topicIdIndexfrom cached repository (ae279e9)