| package | BackPress |
|---|
WP_Object_Cache()
__construct()
add($id, $data, $group= 'default', $expire= 0)
add_global_groups($groups)
add_key_to_group_keys_cache($key, $group)
add_non_persistent_groups($groups)
close()
colorize_debug_line($line)
decr($id, $n, $group)
delete($id, $group = 'default')
delete_all_keys_in_group_key_cache($group)
failure_callback($host, $port)
flush($group = null)
get($id, $group = 'default')
get_mc($group)
get_multi($groups)
incr($id, $n, $group)
key($key, $group)
remove_key_from_group_keys_cache($key, $group)
replace($id, $data, $group= 'default', $expire= 0)
set($id, $data, $group= 'default', $expire= 0)
stats()
$cache
array()$default_expiration
0$global_groups
array('_cache_keys')$group_ops
array()$mc
array()$no_mc_groups
array()$stats
array()WordPress Object Cache
The WordPress Object Cache is used to save on trips to the database. The Object Cache stores all of the cache data to memory and makes the cache contents available by using a key, which is used to name and later retrieve the cache contents.
The Object Cache can be replaced by other caching mechanisms by placing files in the wp-content folder which is looked at in wp-settings. If that file exists, then this file will not be included.
| package | WordPress |
|---|---|
| subpackage | Cache |
| since | 2.0 |
WP_Object_Cache() : \WP_Object_Cache
| since | 2.0.0 |
|---|
\WP_Object_Cache__construct() : null | \WP_Object_Cache
| since | 2.0.8 |
|---|
null\WP_Object_CacheIf cache is disabled, returns null.__destruct() : boolean
Called upon object destruction, which should be when PHP ends.
| since | 2.0.8 |
|---|
booleanTrue value. Won't be used by PHPadd(integer|string $id, mixed $data, string $group= 'default', integer $expire= '') : boolean
| uses | Checks to see if the cache already has data. |
|---|---|
| uses | Sets the data after the checking the cache contents existance. |
| since | 2.0.0 |
integerstringWhat to call the contents in the cache
mixedThe contents to store in the cache
stringWhere to group the cache contents
integerWhen to expire the cache contents
booleanFalse if cache ID and group already exists, true on successadd_global_groups($groups)
add_non_persistent_groups($groups)
delete(integer|string $id, string $group= 'default', boolean $force= false) : boolean
If the cache ID does not exist in the group and $force parameter is set to false, then nothing will happen. The $force parameter is set to false by default.
On success the group and the id will be added to the $non_existant_objects property in the class.
| since | 2.0.0 |
|---|
integerstringWhat the contents in the cache are called
stringWhere the cache contents are grouped
booleanOptional. Whether to force the unsetting of the cache ID in the group
booleanFalse if the contents weren't deleted and true on successflush($group = null) : boolean
| since | 2.0.0 |
|---|
booleanAlways returns trueget(integer|string $id, string $group = 'default') : boolean | mixed
The contents will be first attempted to be retrieved by searching by the ID in the cache group. If the cache is hit (success) then the contents are returned.
On failure, the $non_existant_objects property is checked and if the cache group and ID exist in there the cache misses will not be incremented. If not in the nonexistant objects property, then the cache misses will be incremented and the cache group and ID will be added to the nonexistant objects.
| since | 2.0.0 |
|---|
integerstringWhat the contents in the cache are called
stringWhere the cache contents are grouped
booleanmixedFalse on failure to retrieve contents or the cache
contents on successreplace(integer|string $id, mixed $data, string $group= 'default', integer $expire= '') : boolean
set(integer|string $id, mixed $data, string $group= 'default', integer $expire= '') : boolean
The cache contents is grouped by the $group parameter followed by the $id. This allows for duplicate ids in unique groups. Therefore, naming of the group should be used with care and should follow normal function naming guidelines outside of core WordPress usage.
The $expire parameter is not used, because the cache will automatically expire for each time a page is accessed and PHP finishes. The method is more for cache plugins which use files.
| since | 2.0.0 |
|---|
integerstringWhat to call the contents in the cache
mixedThe contents to store in the cache
stringWhere to group the cache contents
integerNot Used
booleanAlways returns truestats()
Gives the cache hits, and cache misses. Also prints every cached group, key and the data.
| since | 2.0.0 |
|---|
$cache : array
array()| access | private |
|---|---|
| since | 2.0.0 |
$cache_hits : integer
0| since | 2.5.0 |
|---|---|
| access | private |
$cache_misses : integer
0| access | public |
|---|---|
| since | 2.0.0 |
$non_existant_objects : array
array()| access | private |
|---|---|
| since | 2.0.0 |