<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[34227] trunk/src/wp-includes/cache.php: Docs: Improve documentation for the `WP_Object_Cache` class.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/34227">34227</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/34227","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>DrewAPicture</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-09-16 10:02:20 +0000 (Wed, 16 Sep 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Docs: Improve documentation for the `WP_Object_Cache` class.
Spaces out parameter documentation for readability, fixes some minor syntactical issues, and adds some missing `@access` tags or reorders tags according to the PHP docs standards.
Also, documents `&$found`, the fourth parameter for the `get()` method, and adds missing parameter and return descriptions for the `_exists()` utility method.
See <a href="https://core.trac.wordpress.org/ticket/32246">#32246</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludescachephp">trunk/src/wp-includes/cache.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludescachephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/cache.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/cache.php 2015-09-16 09:41:51 UTC (rev 34226)
+++ trunk/src/wp-includes/cache.php 2015-09-16 10:02:20 UTC (rev 34227)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -272,7 +272,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * WordPress Object Cache
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Core class that implements an object cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The WordPress Object Cache is used to save on trips to the database. The
</span><span class="cx" style="display: block; padding: 0 10px"> * Object Cache stores all of the cache data to memory and makes the cache
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -290,11 +290,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Object_Cache {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Holds the cached objects
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Holds the cached objects.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.0.0
+ * @access private
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var array
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access private
- * @since 2.0.0
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private $cache = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -308,43 +308,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> private $cache_hits = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Amount of times the cache did not have the request in cache
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Amount of times the cache did not have the request in cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.0.0
+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var int
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access public
- * @since 2.0.0
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $cache_misses = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * List of global groups
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * List of global cache groups.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 3.0.0
+ * @access protected
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var array
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access protected
- * @since 3.0.0
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $global_groups = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The blog prefix to prepend to keys in non-global groups.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 3.5.0
+ * @access private
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var int
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access private
- * @since 3.5.0
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private $blog_prefix;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Holds the value of `is_multisite()`
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Holds the value of is_multisite().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 3.5.0
+ * @access private
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var bool
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access private
- * @since 3.5.0
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private $multisite;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Make private properties readable for backwards compatibility.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Makes private properties readable for backwards compatibility.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -357,7 +357,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Make private properties settable for backwards compatibility.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Makes private properties settable for backwards compatibility.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -371,7 +371,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Make private properties checkable for backwards compatibility.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Makes private properties checkable for backwards compatibility.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -384,7 +384,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Make private properties un-settable for backwards compatibility.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Makes private properties un-settable for backwards compatibility.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -398,16 +398,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Adds data to the cache if it doesn't already exist.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @uses WP_Object_Cache::_exists Checks to see if the cache already has data.
- * @uses WP_Object_Cache::set Sets the data after the checking the cache
- * contents existence.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key What to call the contents in the cache
- * @param mixed $data The contents to store in the cache
- * @param string $group Where to group the cache contents
- * @param int $expire When to expire the cache contents
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @uses WP_Object_Cache::_exists() Checks to see if the cache already has data.
+ * @uses WP_Object_Cache::set() Sets the data after the checking the cache
+ * contents existence.
+ *
+ * @param int|string $key What to call the contents in the cache.
+ * @param mixed $data The contents to store in the cache.
+ * @param string $group Optional. Where to group the cache contents. Default 'default'.
+ * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration).
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool False if cache key and group already exist, true on success
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function add( $key, $data, $group = 'default', $expire = 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -428,9 +429,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Sets the list of global groups.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the list of global cache groups.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $groups List of groups that are global.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -442,13 +444,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Decrement numeric cache item's value
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Decrements numeric cache item's value.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.3.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key The cache key to decrement.
- * @param int $offset The amount by which to decrement the item's value. Default is 1.
- * @param string $group The group the key is in.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key The cache key to decrement.
+ * @param int $offset Optional. The amount by which to decrement the item's value. Default 1.
+ * @param string $group Optional. The group the key is in. Default 'default'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return false|int False on failure, the item's new value on success.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function decr( $key, $offset = 1, $group = 'default' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -475,17 +478,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Remove the contents of the cache key in the group
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Removes the contents of the cache key in the group.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * If the cache key does not exist in the group, then nothing will happen.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key What the contents in the cache are called
- * @param string $group Where the cache contents are grouped
- * @param bool $deprecated Deprecated.
- *
- * @return bool False if the contents weren't deleted and true on success
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key What the contents in the cache are called.
+ * @param string $group Optional. Where the cache contents are grouped. Default 'default'.
+ * @param bool $deprecated Optional. Unused. Default false.
+ * @return bool False if the contents weren't deleted and true on success.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $key, $group = 'default', $deprecated = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $group ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -502,11 +505,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Clears the object cache of all data
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Clears the object cache of all data.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return true Always returns true
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return true Always returns true.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function flush() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->cache = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -515,7 +519,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves the cache contents, if it exists
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves the cache contents, if it exists.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The contents will be first attempted to be retrieved by searching by the
</span><span class="cx" style="display: block; padding: 0 10px"> * key in the cache group. If the cache is hit (success) then the contents
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -524,12 +528,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * On failure, the number of cache misses will be incremented.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key What the contents in the cache are called
- * @param string $group Where the cache contents are grouped
- * @param string $force Whether to force a refetch rather than relying on the local cache (default is false)
- * @return false|mixed False on failure to retrieve contents or the cache
- * contents on success
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key What the contents in the cache are called.
+ * @param string $group Optional. Where the cache contents are grouped. Default 'default'.
+ * @param string $force Optional. Unused. Whether to force a refetch rather than relying on the local
+ * cache. Default false.
+ * @param bool &$found Optional. Whether the key was found in the cache. Disambiguates a return of
+ * false, a storable value. Passed by reference. Default null.
+ * @return false|mixed False on failure to retrieve contents or the cache contents on success.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get( $key, $group = 'default', $force = false, &$found = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $group ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -553,13 +560,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Increment numeric cache item's value
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Increments numeric cache item's value.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.3.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key The cache key to increment
- * @param int $offset The amount by which to increment the item's value. Default is 1.
- * @param string $group The group the key is in.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key The cache key to increment
+ * @param int $offset Optional. The amount by which to increment the item's value. Default 1.
+ * @param string $group Optional. The group the key is in. Default 'default'.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return false|int False on failure, the item's new value on success.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function incr( $key, $offset = 1, $group = 'default' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -586,16 +594,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Replace the contents in the cache, if contents already exist
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Replaces the contents in the cache, if contents already exist.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see WP_Object_Cache::set()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key What to call the contents in the cache
- * @param mixed $data The contents to store in the cache
- * @param string $group Where to group the cache contents
- * @param int $expire When to expire the cache contents
- * @return bool False if not exists, true if contents were replaced
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key What to call the contents in the cache.
+ * @param mixed $data The contents to store in the cache.
+ * @param string $group Optional. Where to group the cache contents. Default 'default'.
+ * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration).
+ * @return bool False if not exists, true if contents were replaced.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function replace( $key, $data, $group = 'default', $expire = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $group ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -612,9 +622,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Reset keys
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Resets cache keys.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @deprecated 3.5.0 Use switch_to_blog()
</span><span class="cx" style="display: block; padding: 0 10px"> * @see switch_to_blog()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -629,7 +641,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Sets the data contents into the cache
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the data contents into the cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The cache contents is grouped by the $group parameter followed by the
</span><span class="cx" style="display: block; padding: 0 10px"> * $key. This allows for duplicate ids in unique groups. Therefore, naming of
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -641,12 +653,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * more for cache plugins which use files.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|string $key What to call the contents in the cache
- * @param mixed $data The contents to store in the cache
- * @param string $group Where to group the cache contents
- * @param int $expire Not Used
- * @return true Always returns true
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key What to call the contents in the cache.
+ * @param mixed $data The contents to store in the cache.
+ * @param string $group Optional. Where to group the cache contents. Default 'default'.
+ * @param int $expire Not Used.
+ * @return true Always returns true.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set( $key, $data, $group = 'default', $expire = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $group ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -669,6 +682,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * key and the data.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function stats() {
</span><span class="cx" style="display: block; padding: 0 10px"> echo "<p>";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -683,13 +697,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Switch the interal blog id.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Switches the interal blog ID.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * This changes the blog id used to create keys in blog specific groups.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This changes the blog ID used to create keys in blog specific groups.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $blog_id Blog ID
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $blog_id Blog ID.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function switch_to_blog( $blog_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $blog_id = (int) $blog_id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -697,25 +712,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Utility function to determine whether a key exists in the cache.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Serves as a utility function to determine whether a key exists in the cache.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.4.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @access protected
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access protected
- * @param string $key
- * @param string $group
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|string $key Cache key to check for existence.
+ * @param string $group Cache group for the key existence check.
+ * @return bool Whether the key exists in the cache for the given group.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function _exists( $key, $group ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Sets up object properties; PHP 5 style constructor
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets up object properties; PHP 5 style constructor.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.8
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global int $blog_id
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @global int $blog_id Global blog ID.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $blog_id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -732,13 +747,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Will save the object cache before object is completely destroyed.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Saves the object cache before object is completely destroyed.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Called upon object destruction, which should be when PHP ends.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 2.0.8
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.0.8
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return true True value. Won't be used by PHP
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return true Always returns true.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __destruct() {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span></span></pre>
</div>
</div>
</body>
</html>