Changeset 9333 for trunk/src/bp-core/bp-core-cache.php
- Timestamp:
- 01/09/2015 07:40:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-cache.php
r9317 r9333 25 25 return prune_super_cache( $cache_path, true ); 26 26 } 27 }28 29 /**30 * Get the root blog cache key, used by our wrapper functions to differentiate31 * which blog to store our cached data in.32 *33 * @since BuddyPress (2.2.0)34 *35 * @param string $key36 * @return string37 */38 function bp_get_root_blog_cache_key( $key = '' ) {39 $root_blog_id = bp_get_root_blog_id();40 return "{$root_blog_id}:{$key}";41 }42 43 /**44 * Retrieves the cache contents from the cache by key and group.45 *46 * @since BuddyPress (2.2.0)47 *48 * @uses wp_cache_get()49 * @see WP_Object_Cache::get()50 *51 * @param int|string $key What the contents in the cache are called52 * @param string $group Where the cache contents are grouped53 * @param bool $force Whether to force an update of the local cache from54 * the persistent cache (default is false)55 * @param bool $found Whether key was found in the cache. Disambiguates a56 * return of false, a storable value.57 * @return bool|mixed False on failure to retrieve contents or the cache58 * contents on success59 */60 function bp_cache_get( $key, $group = '', $force = false, &$found = null ) {61 $cache_key = bp_get_root_blog_cache_key( $key );62 63 return wp_cache_get( $cache_key, $group, $force, $found );64 }65 66 /**67 * Saves the data to the cache.68 *69 * @since BuddyPress (2.2.0)70 *71 * @uses wp_cache_set()72 * @see WP_Object_Cache::set()73 *74 * @param int|string $key What to call the contents in the cache75 * @param mixed $data The contents to store in the cache76 * @param string $group Where to group the cache contents77 * @param int $expire When to expire the cache contents78 * @return bool False on failure, true on success79 */80 function bp_cache_set( $key, $data, $group = '', $expire = 0 ) {81 $cache_key = bp_get_root_blog_cache_key( $key );82 83 return wp_cache_set( $cache_key, $data, $group, $expire );84 }85 86 /**87 * Removes the cache contents matching key and group.88 *89 * @since BuddyPress (2.2.0)90 *91 * @uses wp_cache_delete()92 * @see WP_Object_Cache::delete()93 *94 * @param int|string $key What the contents in the cache are called95 * @param string $group Where the cache contents are grouped96 * @return bool True on successful removal, false on failure97 */98 function bp_cache_delete( $key, $group = '' ) {99 $cache_key = bp_get_root_blog_cache_key( $key );100 101 return wp_cache_delete( $cache_key, $group );102 27 } 103 28
Note: See TracChangeset
for help on using the changeset viewer.