~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-includes/cache.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 * Adds data to the cache, if the cache key doesn't already exist.
13
13
 *
14
14
 * @since 2.0.0
15
 
 * @uses $wp_object_cache Object Cache Class
16
 
 * @see WP_Object_Cache::add()
 
15
 *
 
16
 * @global WP_Object_Cache $wp_object_cache
17
17
 *
18
18
 * @param int|string $key The cache key to use for retrieval later
19
19
 * @param mixed $data The data to add to the cache store
37
37
 *
38
38
 * @since 2.0.0
39
39
 *
40
 
 * @return bool Always returns True
 
40
 * @return true Always returns True
41
41
 */
42
42
function wp_cache_close() {
43
43
        return true;
47
47
 * Decrement numeric cache item's value
48
48
 *
49
49
 * @since 3.3.0
50
 
 * @uses $wp_object_cache Object Cache Class
51
 
 * @see WP_Object_Cache::decr()
 
50
 *
 
51
 * @global WP_Object_Cache $wp_object_cache
52
52
 *
53
53
 * @param int|string $key The cache key to increment
54
54
 * @param int $offset The amount by which to decrement the item's value. Default is 1.
65
65
 * Removes the cache contents matching key and group.
66
66
 *
67
67
 * @since 2.0.0
68
 
 * @uses $wp_object_cache Object Cache Class
69
 
 * @see WP_Object_Cache::delete()
 
68
 *
 
69
 * @global WP_Object_Cache $wp_object_cache
70
70
 *
71
71
 * @param int|string $key What the contents in the cache are called
72
72
 * @param string $group Where the cache contents are grouped
82
82
 * Removes all cache items.
83
83
 *
84
84
 * @since 2.0.0
85
 
 * @uses $wp_object_cache Object Cache Class
86
 
 * @see WP_Object_Cache::flush()
 
85
 *
 
86
 * @global WP_Object_Cache $wp_object_cache
87
87
 *
88
88
 * @return bool False on failure, true on success
89
89
 */
97
97
 * Retrieves the cache contents from the cache by key and group.
98
98
 *
99
99
 * @since 2.0.0
100
 
 * @uses $wp_object_cache Object Cache Class
101
 
 * @see WP_Object_Cache::get()
 
100
 *
 
101
 * @global WP_Object_Cache $wp_object_cache
102
102
 *
103
103
 * @param int|string $key What the contents in the cache are called
104
104
 * @param string $group Where the cache contents are grouped
105
105
 * @param bool $force Whether to force an update of the local cache from the persistent cache (default is false)
106
106
 * @param bool &$found Whether key was found in the cache. Disambiguates a return of false, a storable value.
107
107
 * @return bool|mixed False on failure to retrieve contents or the cache
108
 
 *              contents on success
 
108
 *                            contents on success
109
109
 */
110
110
function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
111
111
        global $wp_object_cache;
117
117
 * Increment numeric cache item's value
118
118
 *
119
119
 * @since 3.3.0
120
 
 * @uses $wp_object_cache Object Cache Class
121
 
 * @see WP_Object_Cache::incr()
 
120
 *
 
121
 * @global WP_Object_Cache $wp_object_cache
122
122
 *
123
123
 * @param int|string $key The cache key to increment
124
124
 * @param int $offset The amount by which to increment the item's value. Default is 1.
135
135
 * Sets up Object Cache Global and assigns it.
136
136
 *
137
137
 * @since 2.0.0
138
 
 * @global WP_Object_Cache $wp_object_cache WordPress Object Cache
 
138
 *
 
139
 * @global WP_Object_Cache $wp_object_cache
139
140
 */
140
141
function wp_cache_init() {
141
142
        $GLOBALS['wp_object_cache'] = new WP_Object_Cache();
145
146
 * Replaces the contents of the cache with new data.
146
147
 *
147
148
 * @since 2.0.0
148
 
 * @uses $wp_object_cache Object Cache Class
149
 
 * @see WP_Object_Cache::replace()
 
149
 *
 
150
 * @global WP_Object_Cache $wp_object_cache
150
151
 *
151
152
 * @param int|string $key What to call the contents in the cache
152
153
 * @param mixed $data The contents to store in the cache
165
166
 *
166
167
 * @since 2.0.0
167
168
 *
168
 
 * @uses $wp_object_cache Object Cache Class
169
 
 * @see WP_Object_Cache::set()
 
169
 * @global WP_Object_Cache $wp_object_cache
170
170
 *
171
171
 * @param int|string $key What to call the contents in the cache
172
172
 * @param mixed $data The contents to store in the cache
187
187
 *
188
188
 * @since 3.5.0
189
189
 *
 
190
 * @global WP_Object_Cache $wp_object_cache
 
191
 *
190
192
 * @param int $blog_id Blog ID
191
193
 */
192
194
function wp_cache_switch_to_blog( $blog_id ) {
193
195
        global $wp_object_cache;
194
196
 
195
 
        return $wp_object_cache->switch_to_blog( $blog_id );
 
197
        $wp_object_cache->switch_to_blog( $blog_id );
196
198
}
197
199
 
198
200
/**
200
202
 *
201
203
 * @since 2.6.0
202
204
 *
 
205
 * @global WP_Object_Cache $wp_object_cache
 
206
 *
203
207
 * @param string|array $groups A group or an array of groups to add
204
208
 */
205
209
function wp_cache_add_global_groups( $groups ) {
206
210
        global $wp_object_cache;
207
211
 
208
 
        return $wp_object_cache->add_global_groups( $groups );
 
212
        $wp_object_cache->add_global_groups( $groups );
209
213
}
210
214
 
211
215
/**
233
237
 *
234
238
 * @since 2.6.0
235
239
 * @deprecated 3.5.0
 
240
 *
 
241
 * @global WP_Object_Cache $wp_object_cache
236
242
 */
237
243
function wp_cache_reset() {
238
244
        _deprecated_function( __FUNCTION__, '3.5' );
239
245
 
240
246
        global $wp_object_cache;
241
247
 
242
 
        return $wp_object_cache->reset();
 
248
        $wp_object_cache->reset();
243
249
}
244
250
 
245
251
/**
477
483
         *
478
484
         * @since 2.0.0
479
485
         *
480
 
         * @return bool Always returns true
 
486
         * @return true Always returns true
481
487
         */
482
488
        public function flush() {
483
 
                $this->cache = array ();
 
489
                $this->cache = array();
484
490
 
485
491
                return true;
486
492
        }
499
505
         * @param int|string $key What the contents in the cache are called
500
506
         * @param string $group Where the cache contents are grouped
501
507
         * @param string $force Whether to force a refetch rather than relying on the local cache (default is false)
502
 
         * @return bool|mixed False on failure to retrieve contents or the cache
503
 
         *              contents on success
 
508
         * @return false|mixed False on failure to retrieve contents or the cache
 
509
         *                             contents on success
504
510
         */
505
511
        public function get( $key, $group = 'default', $force = false, &$found = null ) {
506
512
                if ( empty( $group ) )
616
622
         * @param mixed $data The contents to store in the cache
617
623
         * @param string $group Where to group the cache contents
618
624
         * @param int $expire Not Used
619
 
         * @return bool Always returns true
 
625
         * @return true Always returns true
620
626
         */
621
627
        public function set( $key, $data, $group = 'default', $expire = 0 ) {
622
628
                if ( empty( $group ) )
684
690
         * Sets up object properties; PHP 5 style constructor
685
691
         *
686
692
         * @since 2.0.8
 
693
         *
 
694
     * @global int $blog_id
687
695
         */
688
696
        public function __construct() {
689
697
                global $blog_id;
706
714
         *
707
715
         * @since  2.0.8
708
716
         *
709
 
         * @return bool True value. Won't be used by PHP
 
717
         * @return true True value. Won't be used by PHP
710
718
         */
711
719
        public function __destruct() {
712
720
                return true;