[MediaWiki-commits] [Gerrit] mediawiki...CentralAuth[wmf/1.31.0-wmf.7]: Use the proper cache key method in loadFromCache()

2017-11-08 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/389917 )

Change subject: Use the proper cache key method in loadFromCache()
..


Use the proper cache key method in loadFromCache()

Bug: T17
Change-Id: I9199ad964377dd3d079cb2d55f0a2ea88acdad56
---
M includes/CentralAuthUser.php
1 file changed, 6 insertions(+), 4 deletions(-)

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



diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index 6a842b7..019a08a 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -492,7 +492,7 @@
protected function loadFromCache() {
$cache = ObjectCache::getMainWANInstance();
$data = $cache->getWithSetCallback(
-   $this->getCacheKey(),
+   $this->getCacheKey( $cache ),
$cache::TTL_DAY,
function ( $oldValue, &$ttl, array &$setOpts ) {
$dbr = CentralAuthUtils::getCentralSlaveDB();
@@ -569,10 +569,11 @@
 
/**
 * Generate a valid memcached key for caching the object's data.
+* @param WANObjectCache $cache
 * @return string
 */
-   protected function getCacheKey() {
-   return "centralauth-user-" . md5( $this->mName );
+   protected function getCacheKey( WANObjectCache $cache ) {
+   return $cache->makeGlobalKey( 'centralauth-user', md5( 
$this->mName ) );
}
 
/**
@@ -2905,7 +2906,8 @@
"Quick cache invalidation for global user 
{$this->mName}" );
 
CentralAuthUtils::getCentralDB()->onTransactionPreCommitOrIdle( 
function () {
-   ObjectCache::getMainWANInstance()->delete( 
$this->getCacheKey() );
+   $cache = ObjectCache::getMainWANInstance();
+   $cache->delete( $this->getCacheKey( $cache ) );
} );
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9199ad964377dd3d079cb2d55f0a2ea88acdad56
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.31.0-wmf.7
Gerrit-Owner: Krinkle 
Gerrit-Reviewer: Aaron Schulz 
Gerrit-Reviewer: Chad 
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...CentralAuth[wmf/1.31.0-wmf.7]: Use the proper cache key method in loadFromCache()

2017-11-07 Thread Krinkle (Code Review)
Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389917 )

Change subject: Use the proper cache key method in loadFromCache()
..

Use the proper cache key method in loadFromCache()

Bug: T17
Change-Id: I9199ad964377dd3d079cb2d55f0a2ea88acdad56
---
M includes/CentralAuthUser.php
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/17/389917/1

diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index 6a842b7..019a08a 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -492,7 +492,7 @@
protected function loadFromCache() {
$cache = ObjectCache::getMainWANInstance();
$data = $cache->getWithSetCallback(
-   $this->getCacheKey(),
+   $this->getCacheKey( $cache ),
$cache::TTL_DAY,
function ( $oldValue, &$ttl, array &$setOpts ) {
$dbr = CentralAuthUtils::getCentralSlaveDB();
@@ -569,10 +569,11 @@
 
/**
 * Generate a valid memcached key for caching the object's data.
+* @param WANObjectCache $cache
 * @return string
 */
-   protected function getCacheKey() {
-   return "centralauth-user-" . md5( $this->mName );
+   protected function getCacheKey( WANObjectCache $cache ) {
+   return $cache->makeGlobalKey( 'centralauth-user', md5( 
$this->mName ) );
}
 
/**
@@ -2905,7 +2906,8 @@
"Quick cache invalidation for global user 
{$this->mName}" );
 
CentralAuthUtils::getCentralDB()->onTransactionPreCommitOrIdle( 
function () {
-   ObjectCache::getMainWANInstance()->delete( 
$this->getCacheKey() );
+   $cache = ObjectCache::getMainWANInstance();
+   $cache->delete( $this->getCacheKey( $cache ) );
} );
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9199ad964377dd3d079cb2d55f0a2ea88acdad56
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.31.0-wmf.7
Gerrit-Owner: Krinkle 
Gerrit-Reviewer: Aaron Schulz 

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