Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-1294

AbstractItemListModel should cache query result

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Do
    • Neutral
    • None
    • 2.7
    • None
    • None

    Description

      When displaying event overview or event calendar the query to find event pages is executed unnecessarily often. In calendar.ftl each item is rendered along with its css and link, each time one of those attributes is touched the query is executed again. The link appears twice in the markup so for each item the query is executed 3 times. Making the number of queries executed be: 1 + number_of_hits*3. AbstractItemListModel is used by more than just calendar.ftl.

      Adding caching in AbstractItemListModel#getItems can significantly improve the performance. A condition could be added to only cache if the result is not larger than a predefined limit.

      A simple test with the following change reduced the time to run the integration tests by 47 seconds on machine, a reduction of 17%.

          private List<Node> itemsList = null;
      
          public Collection<Node> getItems() throws RepositoryException {
              if (itemsList != null)
                  return itemsList;
              itemsList = search();
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              tmattsson Tobias Mattsson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: