Skip to content

Create static TopicIndex cache #116

Description

@JeremyCaney

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

Metadata

Metadata

Assignees

Labels

Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Priority: 1Severity 2: MajorStatus 5: CompleteTask is considered complete, and ready for deployment.Type: ImprovementImproves the functionality or interface of an existing feature.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions