Skip to content

Conversation

wakku9780
Copy link

Summary

Cached child categories as full Category objects instead of IDs to avoid extra DB lookups.

Replaced List with HashSet in breadcrumb building for O(1) lookups.

Motivation
Previously, category tree expansion and breadcrumb building triggered unnecessary DB queries and slow List.Contains checks on deep hierarchies.

Changes

Updated GetChildCategoryIdsAsync:

Cache now stores Dictionary<int, List> instead of Dictionary<int, List>.

Updated GetCategoryBreadCrumbAsync:

Use HashSet for alreadyProcessedCategoryIds.

Impact

Fewer database queries after cache warm-up.

Faster breadcrumb generation with reduced CPU overhead.

No changes in external behavior or APIs.

Testing

Verified via SQL logs: fewer DB queries after repeated category/breadcrumb requests.

UI results remain unchanged.

Risk / Compatibility

Low. Cache key unchanged.

Only internal CategoryService usage updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants