BryanDavis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393363 )

Change subject: Cache results for duration of override
......................................................................

Cache results for duration of override

Purging of cache on record change was introduced in 147b945 so it is
safe for us to cache a throttle override until its current expiration
time on successful lookup. The cache time for a negative lookup is kept
at one hour, not because a longer duration would be unsafe, but because
the key space is incredibly large (2^32 + 2^128).

Change-Id: I049d20f93b0d66f4109778e4e664d2f73c88ae24
---
M ThrottleOverride.hooks.php
1 file changed, 4 insertions(+), 13 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ThrottleOverride 
refs/changes/63/393363/1

diff --git a/ThrottleOverride.hooks.php b/ThrottleOverride.hooks.php
index 9dcaa3d..e4cde1a 100644
--- a/ThrottleOverride.hooks.php
+++ b/ThrottleOverride.hooks.php
@@ -84,21 +84,12 @@
                                        [ 'ORDER BY' => 'thr_expiry DESC' ]
                                );
 
-                               // Its tempting to set the TTL to match the 
expiration we
-                               // found in the DB, but since the record is 
editable and we do
-                               // not purge every key in the range when it 
changes we will
-                               // just leave the default cache time alone. The 
exception to
-                               // this rule is when we are caching a row which 
will expire in
-                               // less than the default TTL.
-                               // NOTE: this means that changes to an existing 
record may not
-                               // effect all IPs in the range equally until 
the default cache
-                               // period has elapsed.
                                if ( $expiry !== false ) {
-                                       // An override exists; do not cache for 
more than the
-                                       // override's current-time-left
+                                       // An override exists; cache for the 
override's
+                                       // current-time-left. Cache will be 
purged via checkKey
+                                       // updates on record modification.
                                        $nowUnix = time();
-                                       $overrideCTL = wfTimestamp( TS_UNIX, 
$expiry ) - $nowUnix;
-                                       $ttl = min( $ttl, max( $overrideCTL, 1 
) );
+                                       $ttl = wfTimestamp( TS_UNIX, $expiry ) 
- $nowUnix;
                                }
 
                                // If we return false the value will not be 
cached

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I049d20f93b0d66f4109778e4e664d2f73c88ae24
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ThrottleOverride
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

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

Reply via email to