Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-2564

Store and reuse promises in CoreSite

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: DEV backlog
    • Fix Version/s: None
    • Component/s: Web Services
    • Labels:

      Description

      Right now in CoreWSProvider we store the promises and reuse them to prevent duplicated WS calls. This has been a great improvement in the app.

      However, I noticed a case where this doesn't work. In a place where the same WS call is made twice with a bit of delay we have this race condition:

      1. First call starts, checks if it's in cache.
      2. First call is not in cache, starts the WS call.
      3. Second call starts, check if it's in cache.
      4. First call ends and starts storing in DB.
      5. Second call is not in cache (yet), starts the WS call (again!).

      We could store the promises in CoreSite like we do in CoreWSProvider. In this case, we should only reuse the promise if the preSets are the same.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dpalou Dani Palou
            Participants:
            Component watchers:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: