[MediaWiki-commits] [Gerrit] mediawiki...FileAnnotations[master]: Rename maybePurge() and remove TTL_UNCACHEABLE optimization

2016-09-19 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Rename maybePurge() and remove TTL_UNCACHEABLE optimization
..


Rename maybePurge() and remove TTL_UNCACHEABLE optimization

The optimization of avoiding set() when WAN cache will reject the
set() is so minor that it is not worth the code being less readable.

Change-Id: I0283ddab0e78503104bd45dafe971a2b76fa7eac
---
M ApiFileAnnotations.php
1 file changed, 7 insertions(+), 16 deletions(-)

Approvals:
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ApiFileAnnotations.php b/ApiFileAnnotations.php
index 73dafbd..c960240 100644
--- a/ApiFileAnnotations.php
+++ b/ApiFileAnnotations.php
@@ -150,11 +150,8 @@
'';
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -217,11 +214,8 @@
'';
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -329,11 +323,8 @@
}
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -495,7 +486,7 @@
 * @param string $cacheKey
 * @return bool Whether key was purged
 */
-   private static function maybePurge( $safeAsOf, $oldValue, $html, 
$cache, $cacheKey ) {
+   private static function purgeIfOutdated( $safeAsOf, $oldValue, $html, 
$cache, $cacheKey ) {
if ( $safeAsOf && $oldValue !== false && $oldValue !== $html ) {
// User possibly expecting to see the new value and it 
does not match.
// Delete the key from all datacenters and yeild the 
new value.

-- 
To view, visit https://gerrit.wikimedia.org/r/311460
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0283ddab0e78503104bd45dafe971a2b76fa7eac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FileAnnotations
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 
Gerrit-Reviewer: MarkTraceur 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...FileAnnotations[master]: Rename maybePurge() and remove TTL_UNCACHEABLE optimization

2016-09-19 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311460

Change subject: Rename maybePurge() and remove TTL_UNCACHEABLE optimization
..

Rename maybePurge() and remove TTL_UNCACHEABLE optimization

The optimization of avoiding set() when WAN cache will reject the
set() is so minor that it is not worth the code being less readable.

Change-Id: I0283ddab0e78503104bd45dafe971a2b76fa7eac
---
M ApiFileAnnotations.php
1 file changed, 7 insertions(+), 16 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileAnnotations 
refs/changes/60/311460/1

diff --git a/ApiFileAnnotations.php b/ApiFileAnnotations.php
index 73dafbd..c960240 100644
--- a/ApiFileAnnotations.php
+++ b/ApiFileAnnotations.php
@@ -150,11 +150,8 @@
'';
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -217,11 +214,8 @@
'';
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -329,11 +323,8 @@
}
 
$setOpts['staleTTL'] = self::MAX_CACHE_TTL;
-   if ( self::maybePurge( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey ) ) {
-   $ttl = $cache::TTL_UNCACHEABLE; // 
don't bother; tombstoned by delete()
-   } else {
-   $ttl = self::elasticCacheTTL( 
$oldValue, $html, $oldAsOf, $ttl );
-   }
+   self::purgeIfOutdated( $safeAsOf, $oldValue, 
$html, $cache, $cacheKey );
+   $ttl = self::elasticCacheTTL( $oldValue, $html, 
$oldAsOf, $ttl );
 
return $html;
},
@@ -495,7 +486,7 @@
 * @param string $cacheKey
 * @return bool Whether key was purged
 */
-   private static function maybePurge( $safeAsOf, $oldValue, $html, 
$cache, $cacheKey ) {
+   private static function purgeIfOutdated( $safeAsOf, $oldValue, $html, 
$cache, $cacheKey ) {
if ( $safeAsOf && $oldValue !== false && $oldValue !== $html ) {
// User possibly expecting to see the new value and it 
does not match.
// Delete the key from all datacenters and yeild the 
new value.

-- 
To view, visit https://gerrit.wikimedia.org/r/311460
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0283ddab0e78503104bd45dafe971a2b76fa7eac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FileAnnotations
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits