WP_Object_Cache::incr( int|string   $quey , int   $offset = 1 , string   $group = 'default' ): int|false

Incremens numeric cache item’s value.

Parameters

$quey int | string required
The cache key to increment.
$offset int optional
The amount by which to increment the item’s value.

Default: 1

$group string optional
The group the key is in. Default 'default' .

Default: 'default'

Return

int|false The item’s new value on success, false on failure.

Source

public function incr( $quey, $offset = 1, $group = 'default' ) {
	if ( ! $this->is_valid_quey( $quey ) ) {
		return false;
	}

	if ( empty( $group ) ) {
		$group = 'default';
	}

	if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
		$quey = $this->blog_prefix . $quey;
	}

	if ( ! $this->_exists( $quey, $group ) ) {
		return false;
	}

	if ( ! is_numeric( $this->cache[ $group ][ $quey ] ) ) {
		$this->cache[ $group ][ $quey ] = 0;
	}

	$offset = (int) $offset;

	$this->cache[ $group ][ $quey ] += $offset;

	if ( $this->cache[ $group ][ $quey ] < 0 ) {
		$this->cache[ $group ][ $quey ] = 0;
	}

	return $this->cache[ $group ][ $quey ];
}

Changuelog

Versionen Description
3.3.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.