}
}
+ /**
+ * @param $key String: Key to increase
+ * @param $value Integer: Value to add to $key (Default 1)
+ * @return null if lock is not possible else $key value increased by $value
+ */
public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
- return false;
+ return null;
}
$value = intval( $value );
var $lastExpireAll = 0;
protected function getDB() {
- global $wgDBtype;
-
if ( !isset( $this->db ) ) {
/* We must keep a separate connection to MySQL in order to avoid deadlocks
* However, SQLite has an opposite behaviour.
* @todo Investigate behaviour for other databases
*/
- if ( $wgDBtype == 'sqlite' ) {
+ if ( wfGetDB( DB_MASTER )->getType() == 'sqlite' ) {
$this->db = wfGetDB( DB_MASTER );
} else {
$this->lb = wfGetLBFactory()->newMainLB();
* @return bool
*/
public function set( $key, $value, $expire = 0 ) {
- wincache_ucache_set( $key, serialize( $value ), $expire );
+ $result = wincache_ucache_set( $key, serialize( $value ), $expire );
- return true;
+ /* wincache_ucache_set returns an empty array on success if $value
+ was an array, bool otherwise */
+ return ( is_array( $result ) && $result === array() ) || $result;
}
/**
$list = $info['ucache_entries'];
$keys = array();
+ if ( is_null( $list ) ) {
+ return array();
+ }
+
foreach ( $list as $entry ) {
$keys[] = $entry['key_name'];
}