* @version 0.1.2
*/
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
+
// {{{ requirements
// }}}
* @var array
* @access public
*/
- var $stats;
+ public $stats;
// }}}
// {{{ private
* @var array
* @access private
*/
- var $_cache_sock;
+ public $_cache_sock;
/**
* Current debug status; 0 - none to 9 - profiling
* @var bool
* @access private
*/
- var $_debug;
+ public $_debug;
/**
* Dead hosts, assoc array, 'host'=>'unixtime when ok to check again'
* @var array
* @access private
*/
- var $_host_dead;
+ public $_host_dead;
/**
* Is compression available?
* @var bool
* @access private
*/
- var $_have_zlib;
+ public $_have_zlib;
/**
* Do we want to use compression?
* @var bool
* @access private
*/
- var $_compress_enable;
+ public $_compress_enable;
/**
* At how many bytes should we compress?
* @var int
* @access private
*/
- var $_compress_threshold;
+ public $_compress_threshold;
/**
* Are we using persistent links?
* @var bool
* @access private
*/
- var $_persistent;
+ public $_persistent;
/**
* If only using one server; contains ip:port to connect to
* @var string
* @access private
*/
- var $_single_sock;
+ public $_single_sock;
/**
* Array containing ip:port or array(ip:port, weight)
* @var array
* @access private
*/
- var $_servers;
+ public $_servers;
/**
* Our bit buckets
* @var array
* @access private
*/
- var $_buckets;
+ public $_buckets;
/**
* Total # of bit buckets we have
* @var int
* @access private
*/
- var $_bucketcount;
+ public $_bucketcount;
/**
* # of total servers we have
* @var int
* @access private
*/
- var $_active;
+ public $_active;
/**
* Stream timeout in seconds. Applies for example to fread()
* @var int
* @access private
*/
- var $_timeout_seconds;
+ public $_timeout_seconds;
/**
* Stream timeout in microseconds
* @var int
* @access private
*/
- var $_timeout_microseconds;
+ public $_timeout_microseconds;
/**
* Connect timeout in seconds
*/
- var $_connect_timeout;
+ public $_connect_timeout;
/**
* Number of connection attempts for each server
*/
- var $_connect_attempts;
+ public $_connect_attempts;
+
+ /**
+ * @var LoggerInterface
+ */
+ private $_logger;
// }}}
// }}}
$this->_connect_timeout = isset( $args['connect_timeout'] ) ? $args['connect_timeout'] : 0.1;
$this->_connect_attempts = 2;
+
+ $this->_logger = isset( $args['logger'] ) ? $args['logger'] : new NullLogger();
}
// }}}
* @return mixed
*/
public function get( $key, &$casToken = null ) {
- wfProfileIn( __METHOD__ );
if ( $this->_debug ) {
$this->_debugprint( "get($key)\n" );
if ( !is_array( $key ) && strval( $key ) === '' ) {
$this->_debugprint( "Skipping key which equals to an empty string" );
- wfProfileOut( __METHOD__ );
return false;
}
if ( !$this->_active ) {
- wfProfileOut( __METHOD__ );
return false;
}
$sock = $this->get_sock( $key );
if ( !is_resource( $sock ) ) {
- wfProfileOut( __METHOD__ );
return false;
}
$cmd = "gets $key\r\n";
if ( !$this->_fwrite( $sock, $cmd ) ) {
- wfProfileOut( __METHOD__ );
return false;
}
if ( isset( $val[$key] ) ) {
$value = $val[$key];
}
- wfProfileOut( __METHOD__ );
return $value;
}
* @param string $text
*/
function _debugprint( $text ) {
- wfDebugLog( 'memcached', $text );
+ $this->_logger->debug( $text );
}
/**
* @param string $text
*/
function _error_log( $text ) {
- wfDebugLog( 'memcached-serious', "Memcached error: $text" );
+ $this->_logger->error( "Memcached error: $text" );
}
/**