mirror of
https://github.com/nasa/openmct.git
synced 2025-05-07 11:08:34 +00:00
[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:
parent
ec0cc572f6
commit
ddbb72b88a
@ -32,7 +32,6 @@ define([], function () {
|
|||||||
*/
|
*/
|
||||||
function ModelCacheService() {
|
function ModelCacheService() {
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
this.cached = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +40,6 @@ define([], function () {
|
|||||||
* @param {object} model the domain object's model
|
* @param {object} model the domain object's model
|
||||||
*/
|
*/
|
||||||
ModelCacheService.prototype.put = function (id, model) {
|
ModelCacheService.prototype.put = function (id, model) {
|
||||||
this.cached[id] = true;
|
|
||||||
this.cache[id] = model;
|
this.cache[id] = model;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ define([], function () {
|
|||||||
* @returns {boolean} true if present; false if not
|
* @returns {boolean} true if present; false if not
|
||||||
*/
|
*/
|
||||||
ModelCacheService.prototype.has = function (id) {
|
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
|
* @param {string} id the domain object's identifier
|
||||||
*/
|
*/
|
||||||
ModelCacheService.prototype.remove = function (id) {
|
ModelCacheService.prototype.remove = function (id) {
|
||||||
delete this.cached[id];
|
|
||||||
delete this.cache[id];
|
delete this.cache[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user