Refactor #1544

Implement Category Predecessor Cache

Added by Anonymous 4 months ago. Updated 3 months ago.

Status:ClosedStart date:09/11/2019
Priority:NormalDue date:09/13/2019
Assignee:Pavan Rikhi% Done:


Category:CategoriesSpent time:-
Target version:v0.7.0 - Misc Pages & UI
Easy Pickings:


Currently, when we need to fetch the predecessors for a category, we do a single query for each level of category nesting.

This gets intensive for some pages, e.g. any page that checks for category sales & the products/category details pages.

Instead, we should keep a Map CategoryId [CategoryId] in the application config that maps a category to a list of it's predecessors. Then we can simply pull the value out of there instead of running a ridiculous amount of many queries.

Make sure to update the map when changes are made to the categories via the Category Admin.

Associated revisions

Revision ec1c81fd
Added by Pavan Rikhi 3 months ago

[#1544] Add Caching for Category Predecessors

Add a Cache module containing types & functions for building a cached
Map from CategoryIds to a list of that Category's predecessor

This cache is initialized when the server starts & is stored in a
thread-safe TVar. Resyncing is not necessary at this point, but will be
required when the Category admin page is implemented and the category
hierarchy can change.

Modify the getParentCategories function in the Models.Utils module to
use the CategoryPredecessorCache to get the parent categories instead of
recursive SQL queries.

Add helper functions to the Server module for reading & writing to the

Closes #1544


#1 Updated by Pavan Rikhi 3 months ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

#2 Updated by Pavan Rikhi 3 months ago

  • Start date set to 09/11/2019
  • Assignee changed from Anonymous to Pavan Rikhi
  • Due date set to 09/13/2019

Also available in: Atom PDF