Edit File by line
/home/barbar84/www/wp-inclu...
File: cache.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Object Cache API
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://codex.wordpress.org/Class_Reference/WP_Object_Cache
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Cache
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/** WP_Object_Cache class */
[10] Fix | Delete
require_once ABSPATH . WPINC . '/class-wp-object-cache.php';
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Adds data to the cache, if the cache key doesn't already exist.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 2.0.0
[16] Fix | Delete
*
[17] Fix | Delete
* @see WP_Object_Cache::add()
[18] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[19] Fix | Delete
*
[20] Fix | Delete
* @param int|string $key The cache key to use for retrieval later.
[21] Fix | Delete
* @param mixed $data The data to add to the cache.
[22] Fix | Delete
* @param string $group Optional. The group to add the cache to. Enables the same key
[23] Fix | Delete
* to be used across groups. Default empty.
[24] Fix | Delete
* @param int $expire Optional. When the cache data should expire, in seconds.
[25] Fix | Delete
* Default 0 (no expiration).
[26] Fix | Delete
* @return bool True on success, false if cache key and group already exist.
[27] Fix | Delete
*/
[28] Fix | Delete
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
[29] Fix | Delete
global $wp_object_cache;
[30] Fix | Delete
[31] Fix | Delete
return $wp_object_cache->add( $key, $data, $group, (int) $expire );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Closes the cache.
[36] Fix | Delete
*
[37] Fix | Delete
* This function has ceased to do anything since WordPress 2.5. The
[38] Fix | Delete
* functionality was removed along with the rest of the persistent cache.
[39] Fix | Delete
*
[40] Fix | Delete
* This does not mean that plugins can't implement this function when they need
[41] Fix | Delete
* to make sure that the cache is cleaned up after WordPress no longer needs it.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 2.0.0
[44] Fix | Delete
*
[45] Fix | Delete
* @return true Always returns true.
[46] Fix | Delete
*/
[47] Fix | Delete
function wp_cache_close() {
[48] Fix | Delete
return true;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Decrements numeric cache item's value.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 3.3.0
[55] Fix | Delete
*
[56] Fix | Delete
* @see WP_Object_Cache::decr()
[57] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[58] Fix | Delete
*
[59] Fix | Delete
* @param int|string $key The cache key to decrement.
[60] Fix | Delete
* @param int $offset Optional. The amount by which to decrement the item's value. Default 1.
[61] Fix | Delete
* @param string $group Optional. The group the key is in. Default empty.
[62] Fix | Delete
* @return int|false The item's new value on success, false on failure.
[63] Fix | Delete
*/
[64] Fix | Delete
function wp_cache_decr( $key, $offset = 1, $group = '' ) {
[65] Fix | Delete
global $wp_object_cache;
[66] Fix | Delete
[67] Fix | Delete
return $wp_object_cache->decr( $key, $offset, $group );
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Removes the cache contents matching key and group.
[72] Fix | Delete
*
[73] Fix | Delete
* @since 2.0.0
[74] Fix | Delete
*
[75] Fix | Delete
* @see WP_Object_Cache::delete()
[76] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[77] Fix | Delete
*
[78] Fix | Delete
* @param int|string $key What the contents in the cache are called.
[79] Fix | Delete
* @param string $group Optional. Where the cache contents are grouped. Default empty.
[80] Fix | Delete
* @return bool True on successful removal, false on failure.
[81] Fix | Delete
*/
[82] Fix | Delete
function wp_cache_delete( $key, $group = '' ) {
[83] Fix | Delete
global $wp_object_cache;
[84] Fix | Delete
[85] Fix | Delete
return $wp_object_cache->delete( $key, $group );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Removes all cache items.
[90] Fix | Delete
*
[91] Fix | Delete
* @since 2.0.0
[92] Fix | Delete
*
[93] Fix | Delete
* @see WP_Object_Cache::flush()
[94] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[95] Fix | Delete
*
[96] Fix | Delete
* @return bool True on success, false on failure.
[97] Fix | Delete
*/
[98] Fix | Delete
function wp_cache_flush() {
[99] Fix | Delete
global $wp_object_cache;
[100] Fix | Delete
[101] Fix | Delete
return $wp_object_cache->flush();
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Retrieves the cache contents from the cache by key and group.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 2.0.0
[108] Fix | Delete
*
[109] Fix | Delete
* @see WP_Object_Cache::get()
[110] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[111] Fix | Delete
*
[112] Fix | Delete
* @param int|string $key The key under which the cache contents are stored.
[113] Fix | Delete
* @param string $group Optional. Where the cache contents are grouped. Default empty.
[114] Fix | Delete
* @param bool $force Optional. Whether to force an update of the local cache
[115] Fix | Delete
* from the persistent cache. Default false.
[116] Fix | Delete
* @param bool $found Optional. Whether the key was found in the cache (passed by reference).
[117] Fix | Delete
* Disambiguates a return of false, a storable value. Default null.
[118] Fix | Delete
* @return mixed|false The cache contents on success, false on failure to retrieve contents.
[119] Fix | Delete
*/
[120] Fix | Delete
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
[121] Fix | Delete
global $wp_object_cache;
[122] Fix | Delete
[123] Fix | Delete
return $wp_object_cache->get( $key, $group, $force, $found );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Retrieves multiple values from the cache in one call.
[128] Fix | Delete
*
[129] Fix | Delete
* @since 5.5.0
[130] Fix | Delete
*
[131] Fix | Delete
* @see WP_Object_Cache::get_multiple()
[132] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[133] Fix | Delete
*
[134] Fix | Delete
* @param array $keys Array of keys under which the cache contents are stored.
[135] Fix | Delete
* @param string $group Optional. Where the cache contents are grouped. Default empty.
[136] Fix | Delete
* @param bool $force Optional. Whether to force an update of the local cache
[137] Fix | Delete
* from the persistent cache. Default false.
[138] Fix | Delete
* @return array Array of values organized into groups.
[139] Fix | Delete
*/
[140] Fix | Delete
function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
[141] Fix | Delete
global $wp_object_cache;
[142] Fix | Delete
[143] Fix | Delete
return $wp_object_cache->get_multiple( $keys, $group, $force );
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
/**
[147] Fix | Delete
* Increment numeric cache item's value
[148] Fix | Delete
*
[149] Fix | Delete
* @since 3.3.0
[150] Fix | Delete
*
[151] Fix | Delete
* @see WP_Object_Cache::incr()
[152] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[153] Fix | Delete
*
[154] Fix | Delete
* @param int|string $key The key for the cache contents that should be incremented.
[155] Fix | Delete
* @param int $offset Optional. The amount by which to increment the item's value. Default 1.
[156] Fix | Delete
* @param string $group Optional. The group the key is in. Default empty.
[157] Fix | Delete
* @return int|false The item's new value on success, false on failure.
[158] Fix | Delete
*/
[159] Fix | Delete
function wp_cache_incr( $key, $offset = 1, $group = '' ) {
[160] Fix | Delete
global $wp_object_cache;
[161] Fix | Delete
[162] Fix | Delete
return $wp_object_cache->incr( $key, $offset, $group );
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Sets up Object Cache Global and assigns it.
[167] Fix | Delete
*
[168] Fix | Delete
* @since 2.0.0
[169] Fix | Delete
*
[170] Fix | Delete
* @global WP_Object_Cache $wp_object_cache
[171] Fix | Delete
*/
[172] Fix | Delete
function wp_cache_init() {
[173] Fix | Delete
$GLOBALS['wp_object_cache'] = new WP_Object_Cache();
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Replaces the contents of the cache with new data.
[178] Fix | Delete
*
[179] Fix | Delete
* @since 2.0.0
[180] Fix | Delete
*
[181] Fix | Delete
* @see WP_Object_Cache::replace()
[182] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[183] Fix | Delete
*
[184] Fix | Delete
* @param int|string $key The key for the cache data that should be replaced.
[185] Fix | Delete
* @param mixed $data The new data to store in the cache.
[186] Fix | Delete
* @param string $group Optional. The group for the cache data that should be replaced.
[187] Fix | Delete
* Default empty.
[188] Fix | Delete
* @param int $expire Optional. When to expire the cache contents, in seconds.
[189] Fix | Delete
* Default 0 (no expiration).
[190] Fix | Delete
* @return bool False if original value does not exist, true if contents were replaced
[191] Fix | Delete
*/
[192] Fix | Delete
function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) {
[193] Fix | Delete
global $wp_object_cache;
[194] Fix | Delete
[195] Fix | Delete
return $wp_object_cache->replace( $key, $data, $group, (int) $expire );
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Saves the data to the cache.
[200] Fix | Delete
*
[201] Fix | Delete
* Differs from wp_cache_add() and wp_cache_replace() in that it will always write data.
[202] Fix | Delete
*
[203] Fix | Delete
* @since 2.0.0
[204] Fix | Delete
*
[205] Fix | Delete
* @see WP_Object_Cache::set()
[206] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[207] Fix | Delete
*
[208] Fix | Delete
* @param int|string $key The cache key to use for retrieval later.
[209] Fix | Delete
* @param mixed $data The contents to store in the cache.
[210] Fix | Delete
* @param string $group Optional. Where to group the cache contents. Enables the same key
[211] Fix | Delete
* to be used across groups. Default empty.
[212] Fix | Delete
* @param int $expire Optional. When to expire the cache contents, in seconds.
[213] Fix | Delete
* Default 0 (no expiration).
[214] Fix | Delete
* @return bool True on success, false on failure.
[215] Fix | Delete
*/
[216] Fix | Delete
function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
[217] Fix | Delete
global $wp_object_cache;
[218] Fix | Delete
[219] Fix | Delete
return $wp_object_cache->set( $key, $data, $group, (int) $expire );
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Switches the internal blog ID.
[224] Fix | Delete
*
[225] Fix | Delete
* This changes the blog id used to create keys in blog specific groups.
[226] Fix | Delete
*
[227] Fix | Delete
* @since 3.5.0
[228] Fix | Delete
*
[229] Fix | Delete
* @see WP_Object_Cache::switch_to_blog()
[230] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[231] Fix | Delete
*
[232] Fix | Delete
* @param int $blog_id Site ID.
[233] Fix | Delete
*/
[234] Fix | Delete
function wp_cache_switch_to_blog( $blog_id ) {
[235] Fix | Delete
global $wp_object_cache;
[236] Fix | Delete
[237] Fix | Delete
$wp_object_cache->switch_to_blog( $blog_id );
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* Adds a group or set of groups to the list of global groups.
[242] Fix | Delete
*
[243] Fix | Delete
* @since 2.6.0
[244] Fix | Delete
*
[245] Fix | Delete
* @see WP_Object_Cache::add_global_groups()
[246] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[247] Fix | Delete
*
[248] Fix | Delete
* @param string|string[] $groups A group or an array of groups to add.
[249] Fix | Delete
*/
[250] Fix | Delete
function wp_cache_add_global_groups( $groups ) {
[251] Fix | Delete
global $wp_object_cache;
[252] Fix | Delete
[253] Fix | Delete
$wp_object_cache->add_global_groups( $groups );
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Adds a group or set of groups to the list of non-persistent groups.
[258] Fix | Delete
*
[259] Fix | Delete
* @since 2.6.0
[260] Fix | Delete
*
[261] Fix | Delete
* @param string|string[] $groups A group or an array of groups to add.
[262] Fix | Delete
*/
[263] Fix | Delete
function wp_cache_add_non_persistent_groups( $groups ) {
[264] Fix | Delete
// Default cache doesn't persist so nothing to do here.
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Reset internal cache keys and structures.
[269] Fix | Delete
*
[270] Fix | Delete
* If the cache back end uses global blog or site IDs as part of its cache keys,
[271] Fix | Delete
* this function instructs the back end to reset those keys and perform any cleanup
[272] Fix | Delete
* since blog or site IDs have changed since cache init.
[273] Fix | Delete
*
[274] Fix | Delete
* This function is deprecated. Use wp_cache_switch_to_blog() instead of this
[275] Fix | Delete
* function when preparing the cache for a blog switch. For clearing the cache
[276] Fix | Delete
* during unit tests, consider using wp_cache_init(). wp_cache_init() is not
[277] Fix | Delete
* recommended outside of unit tests as the performance penalty for using it is
[278] Fix | Delete
* high.
[279] Fix | Delete
*
[280] Fix | Delete
* @since 2.6.0
[281] Fix | Delete
* @deprecated 3.5.0 WP_Object_Cache::reset()
[282] Fix | Delete
* @see WP_Object_Cache::reset()
[283] Fix | Delete
*
[284] Fix | Delete
* @global WP_Object_Cache $wp_object_cache Object cache global instance.
[285] Fix | Delete
*/
[286] Fix | Delete
function wp_cache_reset() {
[287] Fix | Delete
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Object_Cache::reset()' );
[288] Fix | Delete
[289] Fix | Delete
global $wp_object_cache;
[290] Fix | Delete
[291] Fix | Delete
$wp_object_cache->reset();
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function