Converted User touched key to using the WAN cache
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 27 Apr 2015 23:57:08 +0000 (16:57 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 30 Apr 2015 01:30:00 +0000 (01:30 +0000)
Bug: T93141
Change-Id: Id5478d3007bde3f621b4c3ffe9950a654e0ac30a

includes/User.php

index c3d4a65..69d135b 100644 (file)
@@ -2341,15 +2341,14 @@ class User implements IDBAccessObject {
         * @since 1.25
         */
        public function touch() {
-               global $wgMemc;
-
                $this->load();
 
                if ( $this->mId ) {
+                       $this->mQuickTouched = $this->newTouchedTimestamp();
+
+                       $cache = ObjectCache::getMainWANInstance();
                        $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
-                       $timestamp = $this->newTouchedTimestamp();
-                       $wgMemc->set( $key, $timestamp );
-                       $this->mQuickTouched = $timestamp;
+                       $cache->touchCheckKey( $key );
                }
        }
 
@@ -2367,16 +2366,16 @@ class User implements IDBAccessObject {
         * @return string TS_MW Timestamp
         */
        public function getTouched() {
-               global $wgMemc;
-
                $this->load();
 
                if ( $this->mId ) {
                        if ( $this->mQuickTouched === null ) {
+                               $cache = ObjectCache::getMainWANInstance();
                                $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
-                               $timestamp = $wgMemc->get( $key );
+
+                               $timestamp = $cache->getCheckKeyTime( $key );
                                if ( $timestamp ) {
-                                       $this->mQuickTouched = $timestamp;
+                                       $this->mQuickTouched = wfTimestamp( TS_MW, $timestamp );
                                } else {
                                        # Set the timestamp to get HTTP 304 cache hits
                                        $this->touch();