Skip to content

Commit

Permalink
perf(DCOSStore): cache service tree and flat service tree
Browse files Browse the repository at this point in the history
Closes DCOS-37477
  • Loading branch information
Daniel Schmidt committed May 25, 2018
1 parent e777300 commit efdfadf
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/js/stores/DCOSStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class DCOSStore extends EventEmitter {
);
});

this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand Down Expand Up @@ -237,6 +238,7 @@ class DCOSStore extends EventEmitter {
// Populate deployments with services data immediately
this.onMarathonDeploymentsChange();

this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand Down Expand Up @@ -280,6 +282,7 @@ class DCOSStore extends EventEmitter {
}
});

this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand All @@ -295,6 +298,7 @@ class DCOSStore extends EventEmitter {

currentVersions.set(versionID, version);

this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand All @@ -308,6 +312,7 @@ class DCOSStore extends EventEmitter {
}

versions.set(serviceID, nextVersions);
this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand All @@ -318,6 +323,7 @@ class DCOSStore extends EventEmitter {
}

this.data.mesos = states;
this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand All @@ -328,6 +334,7 @@ class DCOSStore extends EventEmitter {
metronome.jobTree = MetronomeStore.jobTree;
metronome.dataReceived = true;

this.clearServiceTreeCache();
this.emit(DCOS_CHANGE);
}

Expand Down Expand Up @@ -402,7 +409,19 @@ class DCOSStore extends EventEmitter {
* @type {ServiceTree}
*/
get serviceTree() {
return this.buildServiceTree();
if (!this._serviceTree) {
this.serviceTree = this.buildServiceTree();
}

return this._serviceTree;
}

set serviceTree(newValue) {
this._serviceTree = newValue;
}

clearServiceTreeCache() {
this.serviceTree = null;
}

buildServiceTree() {
Expand Down

0 comments on commit efdfadf

Please sign in to comment.