Code Duplication    Length = 22-22 lines in 2 locations

wp-includes/cache.php 2 locations

@@ 457-478 (lines=22) @@
454
	 * @param string     $group  Optional. The group the key is in. Default 'default'.
455
	 * @return false|int False on failure, the item's new value on success.
456
	 */
457
	public function decr( $key, $offset = 1, $group = 'default' ) {
458
		if ( empty( $group ) )
459
			$group = 'default';
460
461
		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
462
			$key = $this->blog_prefix . $key;
463
464
		if ( ! $this->_exists( $key, $group ) )
465
			return false;
466
467
		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
468
			$this->cache[ $group ][ $key ] = 0;
469
470
		$offset = (int) $offset;
471
472
		$this->cache[ $group ][ $key ] -= $offset;
473
474
		if ( $this->cache[ $group ][ $key ] < 0 )
475
			$this->cache[ $group ][ $key ] = 0;
476
477
		return $this->cache[ $group ][ $key ];
478
	}
479
480
	/**
481
	 * Removes the contents of the cache key in the group.
@@ 573-594 (lines=22) @@
570
	 * @param string     $group  Optional. The group the key is in. Default 'default'.
571
	 * @return false|int False on failure, the item's new value on success.
572
	 */
573
	public function incr( $key, $offset = 1, $group = 'default' ) {
574
		if ( empty( $group ) )
575
			$group = 'default';
576
577
		if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) )
578
			$key = $this->blog_prefix . $key;
579
580
		if ( ! $this->_exists( $key, $group ) )
581
			return false;
582
583
		if ( ! is_numeric( $this->cache[ $group ][ $key ] ) )
584
			$this->cache[ $group ][ $key ] = 0;
585
586
		$offset = (int) $offset;
587
588
		$this->cache[ $group ][ $key ] += $offset;
589
590
		if ( $this->cache[ $group ][ $key ] < 0 )
591
			$this->cache[ $group ][ $key ] = 0;
592
593
		return $this->cache[ $group ][ $key ];
594
	}
595
596
	/**
597
	 * Replaces the contents in the cache, if contents already exist.