Commit f56a0ffb authored by Vincent Bechu's avatar Vincent Bechu

[mappingstorage] cache mapping id to avoid more request

parent 66d13f06
...@@ -208,6 +208,7 @@ ...@@ -208,6 +208,7 @@
this._default_mapping = {}; this._default_mapping = {};
this._mapping_id_memory_dict = {}; this._mapping_id_memory_dict = {};
this._attachment_list = spec.attachment_list || []; this._attachment_list = spec.attachment_list || [];
this._caching_dict = {id: {}};
initializeQueryAndDefaultMapping(this); initializeQueryAndDefaultMapping(this);
} }
...@@ -226,6 +227,12 @@ ...@@ -226,6 +227,12 @@
} }
function getSubStorageId(storage, id, doc) { function getSubStorageId(storage, id, doc) {
if (storage._caching_dict.id.hasOwnProperty(id)) {
return new RSVP.Queue()
.push(function () {
return storage._caching_dict.id[id];
});
}
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
var map_info = storage._map_id || ["equalSubId"]; var map_info = storage._map_id || ["equalSubId"];
...@@ -239,6 +246,10 @@ ...@@ -239,6 +246,10 @@
id, id,
map_info[1] map_info[1]
); );
})
.push(function (sub_id) {
storage._caching_dict.id[id] = sub_id;
return sub_id;
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment