wp/wp-includes/cache-compat.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   136 	 * @see wp_cache_flush_runtime()
   136 	 * @see wp_cache_flush_runtime()
   137 	 *
   137 	 *
   138 	 * @return bool True on success, false on failure.
   138 	 * @return bool True on success, false on failure.
   139 	 */
   139 	 */
   140 	function wp_cache_flush_runtime() {
   140 	function wp_cache_flush_runtime() {
   141 		return wp_using_ext_object_cache() ? false : wp_cache_flush();
   141 		if ( ! wp_cache_supports( 'flush_runtime' ) ) {
   142 	}
   142 			_doing_it_wrong(
   143 endif;
   143 				__FUNCTION__,
       
   144 				__( 'Your object cache implementation does not support flushing the in-memory runtime cache.' ),
       
   145 				'6.1.0'
       
   146 			);
       
   147 
       
   148 			return false;
       
   149 		}
       
   150 
       
   151 		return wp_cache_flush();
       
   152 	}
       
   153 endif;
       
   154 
       
   155 if ( ! function_exists( 'wp_cache_flush_group' ) ) :
       
   156 	/**
       
   157 	 * Removes all cache items in a group, if the object cache implementation supports it.
       
   158 	 *
       
   159 	 * Before calling this function, always check for group flushing support using the
       
   160 	 * `wp_cache_supports( 'flush_group' )` function.
       
   161 	 *
       
   162 	 * @since 6.1.0
       
   163 	 *
       
   164 	 * @see WP_Object_Cache::flush_group()
       
   165 	 * @global WP_Object_Cache $wp_object_cache Object cache global instance.
       
   166 	 *
       
   167 	 * @param string $group Name of group to remove from cache.
       
   168 	 * @return bool True if group was flushed, false otherwise.
       
   169 	 */
       
   170 	function wp_cache_flush_group( $group ) {
       
   171 		global $wp_object_cache;
       
   172 
       
   173 		if ( ! wp_cache_supports( 'flush_group' ) ) {
       
   174 			_doing_it_wrong(
       
   175 				__FUNCTION__,
       
   176 				__( 'Your object cache implementation does not support flushing individual groups.' ),
       
   177 				'6.1.0'
       
   178 			);
       
   179 
       
   180 			return false;
       
   181 		}
       
   182 
       
   183 		return $wp_object_cache->flush_group( $group );
       
   184 	}
       
   185 endif;
       
   186 
       
   187 if ( ! function_exists( 'wp_cache_supports' ) ) :
       
   188 	/**
       
   189 	 * Determines whether the object cache implementation supports a particular feature.
       
   190 	 *
       
   191 	 * @since 6.1.0
       
   192 	 *
       
   193 	 * @param string $feature Name of the feature to check for. Possible values include:
       
   194 	 *                        'add_multiple', 'set_multiple', 'get_multiple', 'delete_multiple',
       
   195 	 *                        'flush_runtime', 'flush_group'.
       
   196 	 * @return bool True if the feature is supported, false otherwise.
       
   197 	 */
       
   198 	function wp_cache_supports( $feature ) {
       
   199 		return false;
       
   200 	}
       
   201 endif;