Proxy_Cache::cache_result( mixed $data, string $cache_key, string $cache_group )
Summary
Caches data.
Parameters
- $data
-
(mixed) (Required) Data to cache.
- $cache_key
-
(string) (Required) Cache key.
- $cache_group
-
(string) (Required) Cache group name.
Source
File: src/BigCommerce/Proxy/Proxy_Cache.php
public function cache_result( $data, $cache_key, $cache_group ) { if ( wp_using_ext_object_cache() ) { wp_cache_set( $cache_key, $data, $cache_group, self::CACHE_TTL ); /** * The Object Cache API doesn't provide a way to delete an entire cache group, so * we build an extra cached value containing all the cached hashes in this group * for use when we need to bust the entire group. See the bust_cache_group method. */ $cache_keys = wp_cache_get( 'cache_keys', $cache_group ); $cache_keys = is_array( $cache_keys ) ? $cache_keys : []; if ( ! in_array( $cache_key, $cache_keys, true ) ) { $cache_keys[] = $cache_key; } wp_cache_set( 'cache_keys', $cache_keys, $cache_group ); } else { set_transient( $cache_key . $cache_group, $data, self::CACHE_TTL ); } }