Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/226727
Change subject: Separate 'isMissing' micro cache from full link data cache
......................................................................
Separate 'isMissing' micro cache from full link data cache
Bug: T106819
Change-Id: I72f52d63968aa1ac842b2aa503150cf114f9d711
---
M modules/ve-mw/init/ve.init.mw.ApiResponseCache.js
M modules/ve-mw/init/ve.init.mw.LinkCache.js
M modules/ve-mw/init/ve.init.mw.Target.js
3 files changed, 30 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/27/226727/1
diff --git a/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js
b/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js
index 636cf1d..9b9e8f7 100644
--- a/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js
+++ b/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js
@@ -115,14 +115,9 @@
* @fires add
*/
ve.init.mw.ApiResponseCache.prototype.set = function ( entries ) {
- var name, hasOwn = Object.prototype.hasOwnProperty;
+ var name;
for ( name in entries ) {
- if ( hasOwn.call( this.cacheValues, name ) ) {
- continue;
- }
- if ( !hasOwn.call( this.deferreds, name ) ) {
- this.deferreds[name] = $.Deferred();
- }
+ this.deferreds[name] = $.Deferred();
this.deferreds[name].resolve( entries[name] );
this.cacheValues[name] = entries[name];
}
diff --git a/modules/ve-mw/init/ve.init.mw.LinkCache.js
b/modules/ve-mw/init/ve.init.mw.LinkCache.js
index a4af640..611fe16 100644
--- a/modules/ve-mw/init/ve.init.mw.LinkCache.js
+++ b/modules/ve-mw/init/ve.init.mw.LinkCache.js
@@ -66,7 +66,17 @@
* @param {jQuery} $element Element to style
*/
ve.init.mw.LinkCache.prototype.styleElement = function ( title, $element ) {
- this.get( title ).done( function ( data ) {
+ var promise,
+ cachedMissingData = this.getCached( '_missing/' + title );
+
+ // Use the synchronous missing link cache data if it exists
+ if ( cachedMissingData ) {
+ promise = $.Deferred().resolve( cachedMissingData ).promise();
+ } else {
+ promise = this.get( title );
+ }
+
+ promise.done( function ( data ) {
if ( data.missing ) {
$element.addClass( 'new' );
} else {
@@ -96,13 +106,28 @@
};
/**
+ * Set link missing data
+ *
+ * Stored separately from the full link data cache
+ *
+ * @param {Object} entries Object keyed by page title, with the values being
data objects
+ */
+ve.init.mw.LinkCache.prototype.setMissing = function ( entries ) {
+ var name, missingEntries = {};
+ for ( name in entries ) {
+ missingEntries['_missing/' + name] = entries[name];
+ }
+ this.set( missingEntries );
+};
+
+/**
* @inheritdoc
*/
ve.init.mw.LinkCache.prototype.get = function ( title ) {
var data = {};
if ( this.assumeExistence ) {
data[this.constructor.static.normalizeTitle( title )] = {
missing: false };
- this.set( data );
+ this.setMissing( data );
}
// Parent method
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js
b/modules/ve-mw/init/ve.init.mw.Target.js
index 3682703..63917fc 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -381,7 +381,7 @@
linkData[data.links.known[i]] = {
missing: false };
}
}
- ve.init.platform.linkCache.set( linkData );
+ ve.init.platform.linkCache.setMissing( linkData );
}
ve.track( 'trace.parseResponse.exit' );
--
To view, visit https://gerrit.wikimedia.org/r/226727
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I72f52d63968aa1ac842b2aa503150cf114f9d711
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits