[CacheService] Don't track ids twice

Track whether an object is in the cache based on whether it is
in the cache instead of utilizing a separate object for tracking
contents of cache.

See comment on https://github.com/nasa/openmct/pull/773/files
This commit is contained in:
Pete Richards 2016-03-24 12:57:53 -07:00
parent ec0cc572f6
commit ddbb72b88a

View File

@ -32,7 +32,6 @@ define([], function () {
*/
function ModelCacheService() {
this.cache = {};
this.cached = {};
}
/**
@ -41,7 +40,6 @@ define([], function () {
* @param {object} model the domain object's model
*/
ModelCacheService.prototype.put = function (id, model) {
this.cached[id] = true;
this.cache[id] = model;
};
@ -60,7 +58,7 @@ define([], function () {
* @returns {boolean} true if present; false if not
*/
ModelCacheService.prototype.has = function (id) {
return !!this.cached[id];
return this.cache.hasOwnProperty(id);
};
/**
@ -68,7 +66,6 @@ define([], function () {
* @param {string} id the domain object's identifier
*/
ModelCacheService.prototype.remove = function (id) {
delete this.cached[id];
delete this.cache[id];
};