async notifyDocuments(request, action, documents) {
    const prefix = getCachePrefix(request);
    let cached = action === actionEnum.REPLACE || action === actionEnum.UPDATE;

    const cacheIds = documents.map((doc) => {
      if (
        (action === actionEnum.WRITE || action === actionEnum.UPSERT) &&
        !cached
      ) {
        cached = doc.created !== true; // force a bool value if undefined
      }

      return prefix + doc._id;
    });

    const cache = cached
      ? await global.kuzzle.ask("core:cache:internal:mget", cacheIds)
      : [];

    const result = await Bluebird.map(documents, (doc, index) => {
      switch (action) {
        case actionEnum.CREATE:
          return this.notifyDocumentCreate(request, doc);

        case actionEnum.DELETE:
          return this.notifyDocumentDelete(request, doc);

        case actionEnum.REPLACE:
          return this.notifyDocumentReplace(request, doc, cache[index]);

        case actionEnum.UPDATE:
          return this.notifyDocumentUpdate(request, doc, cache[index]);

        case actionEnum.UPSERT:
          return doc.created
            ? this.notifyDocumentCreate(request, doc)
            : this.notifyDocumentUpdate(request, doc, cache[index]);

        case actionEnum.WRITE:
          return doc.created
            ? this.notifyDocumentCreate(request, doc)
            : this.notifyDocumentReplace(request, doc, cache[index]);

        default:
          throw kerror.get(
            "core",
            "fatal",
            "assertion_failed",
            `unknown notify action "${doc.action}"`,
          );
      }
    });

    const toDelete = [];

    await Bluebird.map(result, (rooms, index) => {
      if (rooms.length > 0) {
        return global.kuzzle.ask(
          "core:cache:internal:store",
          cacheIds[index],
          JSON.stringify(rooms),
          { ttl: this.ttl },
        );
      }

      toDelete.push(cacheIds[index]);
      return null;
    });

    if (toDelete.length > 0) {
      await global.kuzzle.ask("core:cache:internal:del", toDelete);
    }
  }
Computes document notifications and sends them to subscribed users.
@param  {Request} request
@param  {notifyActionEnum} action
@param  {Array.<DocumentChanges>} documents
@return {Promise}