dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "objectcache: Optimise array_map in MemcachedBagOStuff::makeKey()"
[lhc/web/wiklou.git]
/
includes
/
cache
/
FileCacheBase.php
diff --git
a/includes/cache/FileCacheBase.php
b/includes/cache/FileCacheBase.php
index
f2da08a
..
fb42539
100644
(file)
--- a/
includes/cache/FileCacheBase.php
+++ b/
includes/cache/FileCacheBase.php
@@
-179,9
+179,9
@@
abstract class FileCacheBase {
* @return void
*/
public function clearCache() {
* @return void
*/
public function clearCache() {
-
MediaWiki
\suppressWarnings();
+
Wikimedia
\suppressWarnings();
unlink( $this->cachePath() );
unlink( $this->cachePath() );
-
MediaWiki
\restoreWarnings();
+
Wikimedia
\restoreWarnings();
$this->mCached = false;
}
$this->mCached = false;
}
@@
-230,31
+230,26
@@
abstract class FileCacheBase {
*/
public function incrMissesRecent( WebRequest $request ) {
if ( mt_rand( 0, self::MISS_FACTOR - 1 ) == 0 ) {
*/
public function incrMissesRecent( WebRequest $request ) {
if ( mt_rand( 0, self::MISS_FACTOR - 1 ) == 0 ) {
- $cache = ObjectCache::getLocalClusterInstance();
# Get a large IP range that should include the user even if that
# person's IP address changes
$ip = $request->getIP();
if ( !IP::isValid( $ip ) ) {
return;
}
# Get a large IP range that should include the user even if that
# person's IP address changes
$ip = $request->getIP();
if ( !IP::isValid( $ip ) ) {
return;
}
+
$ip = IP::isIPv6( $ip )
? IP::sanitizeRange( "$ip/32" )
: IP::sanitizeRange( "$ip/16" );
# Bail out if a request already came from this range...
$ip = IP::isIPv6( $ip )
? IP::sanitizeRange( "$ip/32" )
: IP::sanitizeRange( "$ip/16" );
# Bail out if a request already came from this range...
+ $cache = ObjectCache::getLocalClusterInstance();
$key = $cache->makeKey( static::class, 'attempt', $this->mType, $this->mKey, $ip );
$key = $cache->makeKey( static::class, 'attempt', $this->mType, $this->mKey, $ip );
- if (
$cache->get( $key
) ) {
+ if (
!$cache->add( $key, 1, self::MISS_TTL_SEC
) ) {
return; // possibly the same user
}
return; // possibly the same user
}
- $cache->set( $key, 1, self::MISS_TTL_SEC );
# Increment the number of cache misses...
# Increment the number of cache misses...
- $key = $this->cacheMissKey( $cache );
- if ( $cache->get( $key ) === false ) {
- $cache->set( $key, 1, self::MISS_TTL_SEC );
- } else {
- $cache->incr( $key );
- }
+ $cache->incrWithInit( $this->cacheMissKey( $cache ), self::MISS_TTL_SEC );
}
}
}
}