public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
public function incr( $key, $value = 1 ) {
if ( !$this->lock( $key ) ) {
if ( ( $n = $this->get( $key ) ) !== false ) {
$n += $value;
$this->set( $key, $n ); // exptime?
if ( ( $n = $this->get( $key ) ) !== false ) {
$n += $value;
$this->set( $key, $n ); // exptime?
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 ( !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
*/