: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( $this->cache[ $group ][ $key ] < 0 ) {
$this->cache[ $group ][ $key ] = 0;
return $this->cache[ $group ][ $key ];
* Decrements numeric cache item's value.
* @param int|string $key The cache key to decrement.
* @param int $offset Optional. The amount by which to decrement the item's value.
* @param string $group Optional. The group the key is in. Default 'default'.
* @return int|false The item's new value on success, false on failure.
public function decr( $key, $offset = 1, $group = 'default' ) {
if ( ! $this->is_valid_key( $key ) ) {
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
$key = $this->blog_prefix . $key;
if ( ! $this->_exists( $key, $group ) ) {
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
$this->cache[ $group ][ $key ] = 0;
$this->cache[ $group ][ $key ] -= $offset;
if ( $this->cache[ $group ][ $key ] < 0 ) {
$this->cache[ $group ][ $key ] = 0;
return $this->cache[ $group ][ $key ];
* Clears the object cache of all data.
* @return true Always returns true.
public function flush() {
* Removes all cache items in a group.
* @param string $group Name of group to remove from cache.
* @return true Always returns true.
public function flush_group( $group ) {
unset( $this->cache[ $group ] );
* Sets the list of global cache groups.
* @param string|string[] $groups List of groups that are global.
public function add_global_groups( $groups ) {
$groups = (array) $groups;
$groups = array_fill_keys( $groups, true );
$this->global_groups = array_merge( $this->global_groups, $groups );
* Switches the internal blog ID.
* This changes the blog ID used to create keys in blog specific groups.
* @param int $blog_id Blog ID.
public function switch_to_blog( $blog_id ) {
$blog_id = (int) $blog_id;
$this->blog_prefix = $this->multisite ? $blog_id . ':' : '';
* @deprecated 3.5.0 Use WP_Object_Cache::switch_to_blog()
public function reset() {
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Object_Cache::switch_to_blog()' );
// Clear out non-global caches since the blog ID has changed.
foreach ( array_keys( $this->cache ) as $group ) {
if ( ! isset( $this->global_groups[ $group ] ) ) {
unset( $this->cache[ $group ] );
* Echoes the stats of the caching.
* Gives the cache hits, and cache misses. Also prints every cached group,
public function stats() {
echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
foreach ( $this->cache as $group => $cache ) {
echo '<li><strong>Group:</strong> ' . esc_html( $group ) . ' - ( ' . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';