user = $user; $this->key = wfMemcKey( 'echo', 'seen', 'time', $user->getId() ); $this->cache = ObjectCache::getInstance( 'db-replicated' ); } /** * @param User $user * @return EchoSeenTime */ public static function newFromUser( User $user ) { return new self( $user ); } /** * @param int $flags BagOStuff::READ_LATEST to use the master * @return string|bool false if no stored time */ public function getTime( $flags = 0 ) { $cas = 0; // Unused, but we have to pass something by reference $data = $this->cache->get( $this->key, $cas, $flags ); if ( $data === false ) { // Check if the user still has it set in their preferences $data = $this->user->getOption( 'echo-seen-time', false ); } return $data; } public function setTime( $time ) { return $this->cache->set( $this->key, $time ); } }