{"id":54326,"date":"2025-08-13T02:09:46","date_gmt":"2025-08-12T18:09:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54326.html"},"modified":"2025-08-13T02:09:46","modified_gmt":"2025-08-12T18:09:46","slug":"%e8%af%a6%e8%a7%a3-wordpress-wp_cache_get-%e5%92%8c-wp_cache_set-%e5%87%bd%e6%95%b0%e7%9a%84%e6%ba%90%e7%a0%81%ef%bc%9a%e5%9c%a8%e6%b2%a1%e6%9c%89%e5%a4%96%e9%83%a8%e7%bc%93%e5%ad%98%e6%97%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54326.html","title":{"rendered":"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002"},"content":{"rendered":"<p>Alright, gather \u2019round, code wranglers! Let\u2019s talk about WordPress\u2019s internal caching mechanism\u00a0when it\u2019s flying solo, without any fancy external caching plugins. We\u2019re diving deep into wp_cache_get() and wp_cache_set(), the unsung heroes of WordPress performance when no other cache provider is configured.<\/p>\n<p>(Ahem, clears throat, adjusts imaginary glasses) Let\u2019s begin!<\/p>\n<p>The Stage: wp-includes\/cache.php<\/p>\n<p>This is where the magic happens, or rather, the basic magic happens. When you don\u2019t have Memcached, Redis, or some other caching system set up, WordPress relies on its own internal, in-memory object cache. This cache is held in a global variable, $wp_object_cache.<\/p>\n<p>The Players: wp_cache_get() and wp_cache_set()<\/p>\n<p>These two functions are the workhorses. wp_cache_get() retrieves data from the cache, and wp_cache_set() stores data into it.<\/p>\n<p>Scenario 1: No External Cache Provider<\/p>\n<p>If you haven\u2019t installed and activated a persistent object cache plugin (like Memcached Object Cache, Redis Object Cache, etc.), WordPress uses its default, non-persistent object cache. This means the cache exists only for the duration of a single request. Once the page is generated and sent to the user, the cache is wiped clean.<\/p>\n<p>Under the Hood: $wp_object_cache<\/p>\n<p>The $wp_object_cache variable is an instance of the WP_Object_Cache class. Let\u2019s take a look at its structure.<\/p>\n<p>\/**<br \/>\n * Core class used to implement an object cache.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *\/<br \/>\nclass WP_Object_Cache {<\/p>\n<p>    \/**<br \/>\n     * Holds the cached objects.<br \/>\n     *<br \/>\n     * &#064;var array<br \/>\n     *\/<br \/>\n    private $cache &#061; array();<\/p>\n<p>    \/**<br \/>\n     * The number of cache calls.<br \/>\n     *<br \/>\n     * &#064;var int<br \/>\n     *\/<br \/>\n    public $cache_hits &#061; 0;<\/p>\n<p>    \/**<br \/>\n     * Number of times cache missed.<br \/>\n     *<br \/>\n     * &#064;var int<br \/>\n     *\/<br \/>\n    public $cache_misses &#061; 0;<\/p>\n<p>    \/**<br \/>\n     * List of global groups.<br \/>\n     *<br \/>\n     * &#064;var array<br \/>\n     *\/<br \/>\n    protected $global_groups &#061; array();<\/p>\n<p>    \/**<br \/>\n     * List of non-persistent groups.<br \/>\n     *<br \/>\n     * &#064;var array<br \/>\n     *\/<br \/>\n    protected $non_persistent_groups &#061; array();<\/p>\n<p>    \/**<br \/>\n     * Holds the value if WordPress is running in network mode.<br \/>\n     *<br \/>\n     * &#064;var bool<br \/>\n     *\/<br \/>\n    protected $multisite;<\/p>\n<p>    \/**<br \/>\n     * The blog ID.<br \/>\n     *<br \/>\n     * &#064;var int<br \/>\n     *\/<br \/>\n    protected $blog_id;<\/p>\n<p>    \/**<br \/>\n     * Instantiate the cache.<br \/>\n     *<br \/>\n     * &#064;since 2.0.0<br \/>\n     *<br \/>\n     * &#064;global array $wp_db_versions<br \/>\n     *\/<br \/>\n    public function __construct() {<br \/>\n        global $wp_db_versions;<\/p>\n<p>        $this-&gt;multisite &#061; is_multisite();<br \/>\n        $this-&gt;blog_id   &#061; (int) get_current_blog_id();<\/p>\n<p>        if ( function_exists( &#039;wp_cache_add_global_groups&#039; ) ) {<br \/>\n            wp_cache_add_global_groups( (array) $wp_db_versions );<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ &#8230; (Other methods will be discussed later) &#8230;<br \/>\n}<\/p>\n<p>global $wp_object_cache;<\/p>\n<p>if ( ! isset( $wp_object_cache ) ) {<br \/>\n    $wp_object_cache &#061; new WP_Object_Cache();<br \/>\n}<\/p>\n<p>Key things to note:<\/p>\n<ul>\n<li>$cache: This is the heart of the cache. It\u2019s a simple associative array where data is stored. The keys are constructed from the cache key and group.<\/li>\n<li>$cache_hits and $cache_misses: These track how often the cache is successfully used (a &#034;hit&#034;) versus how often it fails to find the requested data (a &#034;miss&#034;). Useful for debugging and performance analysis.<\/li>\n<li>$global_groups and $non_persistent_groups: These are used to manage which groups of cached data should be shared across the entire WordPress installation (global) and which should be specific to a particular site or part of the application (non-persistent). In the context of the internal cache, these groups are generally less crucial than when using a persistent cache.<\/li>\n<\/ul>\n<p>Diving into wp_cache_get()<\/p>\n<p>Let\u2019s dissect the wp_cache_get() function.<\/p>\n<p>\/**<br \/>\n * Retrieves the cache contents, if it exists.<br \/>\n *<br \/>\n * The contents are first attempted to be retrieved from the cache. If the<br \/>\n * cache is empty, then the callback function will be called to generate<br \/>\n * the cache contents. The results of the callback function are stored in the<br \/>\n * cache using the cache key.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *<br \/>\n * &#064;global WP_Object_Cache $wp_object_cache Object cache global instance.<br \/>\n *<br \/>\n * &#064;param int|string $key Cache key.<br \/>\n * &#064;param string     $group Optional. Cache group. Default empty.<br \/>\n * &#064;param bool       $force Optional. Whether to force an update of the local<br \/>\n *                            cache from the persistent cache. Default false.<br \/>\n *<br \/>\n * &#064;return mixed|false Cached data on success, false on failure.<br \/>\n *\/<br \/>\nfunction wp_cache_get( $key, $group &#061; &#039;&#039;, $force &#061; false ) {<br \/>\n    global $wp_object_cache;<\/p>\n<p>    return $wp_object_cache-&gt;get( $key, $group, $force );<br \/>\n}<\/p>\n<p>It\u2019s a simple wrapper around the WP_Object_Cache::get() method. Let\u2019s look at that method:<\/p>\n<p>\/**<br \/>\n * Retrieves the cache contents, if it exists.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *<br \/>\n * &#064;param int|string $key   Cache key.<br \/>\n * &#064;param string     $group Optional. Cache group. Default empty.<br \/>\n * &#064;param bool       $force Optional. Whether to force an update of the local<br \/>\n *                          cache from the persistent cache. Default false.<br \/>\n *<br \/>\n * &#064;return mixed|false Cached data on success, false on failure.<br \/>\n *\/<br \/>\npublic function get( $key, $group &#061; &#039;&#039;, $force &#061; false ) {<br \/>\n    $key &#061; (string) $key;<br \/>\n    $group &#061; (string) $group;<\/p>\n<p>    if ( isset( $this-&gt;cache[ $group ][ $key ] ) ) {<br \/>\n        $this-&gt;cache_hits&#043;&#043;;<br \/>\n        if ( is_object( $this-&gt;cache[ $group ][ $key ] ) ) {<br \/>\n            return clone $this-&gt;cache[ $group ][ $key ];<br \/>\n        } else {<br \/>\n            return $this-&gt;cache[ $group ][ $key ];<br \/>\n        }<br \/>\n    }<\/p>\n<p>    $this-&gt;cache_misses&#043;&#043;;<br \/>\n    return false;<br \/>\n}<\/p>\n<p>Here\u2019s the breakdown:<\/p>\n<li>Type Casting: The $key and $group parameters are cast to strings. This ensures consistent key handling.<\/li>\n<li>Cache Lookup: The code checks if the data exists in the $cache array using $this-&gt;cache[ $group ][ $key ]. The cache is organized in a two-level structure: first by group, then by key within that group.<\/li>\n<li>Cache Hit: If the data is found, $this-&gt;cache_hits is incremented. The data is then returned. Note the clone operation when dealing with objects. This prevents modifications to the cached object from affecting the original data.<\/li>\n<li>Cache Miss: If the data is not found, $this-&gt;cache_misses is incremented, and false is returned.<\/li>\n<p>Example wp_cache_get() Usage:<\/p>\n<p>$my_data &#061; wp_cache_get( &#039;my_unique_key&#039;, &#039;my_group&#039; );<\/p>\n<p>if ( false &#061;&#061;&#061; $my_data ) {<br \/>\n    \/\/ Data not found in cache.  Let&#039;s fetch it from the database or calculate it.<br \/>\n    $my_data &#061; expensive_operation(); \/\/ Replace with your actual data fetching code<\/p>\n<p>    \/\/ Store the data in the cache for future use.<br \/>\n    wp_cache_set( &#039;my_unique_key&#039;, $my_data, &#039;my_group&#039; );<br \/>\n}<\/p>\n<p>\/\/ Now $my_data contains either the cached data or the newly fetched\/calculated data.<br \/>\necho &#034;My data: &#034; . $my_data;<\/p>\n<p>The Star of the Show: wp_cache_set()<\/p>\n<p>Now, let\u2019s explore wp_cache_set().<\/p>\n<p>\/**<br \/>\n * Sets the data contents into the cache.<br \/>\n *<br \/>\n * The cache key and group are used to name the cache and to group the cache<br \/>\n * contents.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *<br \/>\n * &#064;global WP_Object_Cache $wp_object_cache Object cache global instance.<br \/>\n *<br \/>\n * &#064;param int|string $key    Cache key.<br \/>\n * &#064;param mixed      $data   Data to store in the cache.<br \/>\n * &#064;param string     $group  Optional. Cache group. Default empty.<br \/>\n * &#064;param int        $expire Optional. When to expire the cache contents, in seconds.<br \/>\n *                           Default 0 (no expiration).<br \/>\n *<br \/>\n * &#064;return bool False if not an object. True on success.<br \/>\n *\/<br \/>\nfunction wp_cache_set( $key, $data, $group &#061; &#039;&#039;, $expire &#061; 0 ) {<br \/>\n    global $wp_object_cache;<\/p>\n<p>    return $wp_object_cache-&gt;set( $key, $data, $group, $expire );<br \/>\n}<\/p>\n<p>Again, this is a wrapper for the WP_Object_Cache::set() method:<\/p>\n<p>\/**<br \/>\n * Sets the data contents into the cache.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *<br \/>\n * &#064;param int|string $key    Cache key.<br \/>\n * &#064;param mixed      $data   Data to store in the cache.<br \/>\n * &#064;param string     $group  Optional. Cache group. Default empty.<br \/>\n * &#064;param int        $expire Optional. When to expire the cache contents, in seconds.<br \/>\n *                           Default 0 (no expiration).<br \/>\n *<br \/>\n * &#064;return bool False if not an object. True on success.<br \/>\n *\/<br \/>\npublic function set( $key, $data, $group &#061; &#039;&#039;, $expire &#061; 0 ) {<br \/>\n    $key &#061; (string) $key;<br \/>\n    $group &#061; (string) $group;<\/p>\n<p>    if ( is_object( $data ) ) {<br \/>\n        $this-&gt;cache[ $group ][ $key ] &#061; clone $data;<br \/>\n    } else {<br \/>\n        $this-&gt;cache[ $group ][ $key ] &#061; $data;<br \/>\n    }<\/p>\n<p>    return true;<br \/>\n}<\/p>\n<p>The process:<\/p>\n<li>Type Casting: $key and $group are cast to strings, similar to wp_cache_get().<\/li>\n<li>Data Storage: The $data is stored in the $cache array at the location specified by the $group and $key: $this-&gt;cache[ $group ][ $key ] &#061; $data;. Again, if $data is an object, it\u2019s cloned to prevent modification of the original.<\/li>\n<li>Return Value: The function always returns true to indicate success. (Historically, it returned false if the data was not an object, but this behavior has changed.)<\/li>\n<p>Important Considerations with the Internal Cache<\/p>\n<ul>\n<li>Request-Bound: The internal cache is not persistent. Data stored in the cache is only available during the current request. Once the page is generated and sent to the user, the cache is destroyed.<\/li>\n<li>Expiration: The $expire parameter in wp_cache_set() is ignored when using the internal cache. Expiration only comes into play with persistent object caches.<\/li>\n<li>Memory Limits: The internal cache is limited by the PHP memory allocated to WordPress. Caching large amounts of data can lead to memory exhaustion errors. Be mindful of what you\u2019re caching.<\/li>\n<li>Object Cloning: Both wp_cache_get() and wp_cache_set() clone objects before returning or storing them. This is a good practice to prevent accidental modification of the cached data.<\/li>\n<\/ul>\n<p>Global vs. Non-Persistent Groups<\/p>\n<p>Let\u2019s look at how $global_groups and $non_persistent_groups are used.<\/p>\n<p>\/**<br \/>\n * Adds a group to the list of global groups.<br \/>\n *<br \/>\n * &#064;since 2.9.0<br \/>\n *<br \/>\n * &#064;param string|array $groups A group or an array of groups to add.<br \/>\n *\/<br \/>\npublic function add_global_groups( $groups ) {<br \/>\n    if ( ! is_array( $groups ) ) {<br \/>\n        $groups &#061; (array) $groups;<br \/>\n    }<\/p>\n<p>    $this-&gt;global_groups &#061; array_merge( $this-&gt;global_groups, $groups );<br \/>\n    $this-&gt;global_groups &#061; array_unique( $this-&gt;global_groups );<br \/>\n}<\/p>\n<p>\/**<br \/>\n * Adds a group to the list of non-persistent groups.<br \/>\n *<br \/>\n * &#064;since 3.5.0<br \/>\n *<br \/>\n * &#064;param string|array $groups A group or an array of groups to add.<br \/>\n *\/<br \/>\npublic function add_non_persistent_groups( $groups ) {<br \/>\n    if ( ! is_array( $groups ) ) {<br \/>\n        $groups &#061; (array) $groups;<br \/>\n    }<\/p>\n<p>    $this-&gt;non_persistent_groups &#061; array_merge( $this-&gt;non_persistent_groups, $groups );<br \/>\n    $this-&gt;non_persistent_groups &#061; array_unique( $this-&gt;non_persistent_groups );<br \/>\n}<\/p>\n<p>\/**<br \/>\n * Resets internal cache keys and properties.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *\/<br \/>\npublic function reset() {<br \/>\n    $this-&gt;cache       &#061; array();<br \/>\n    $this-&gt;cache_hits  &#061; 0;<br \/>\n    $this-&gt;cache_misses &#061; 0;<br \/>\n}<\/p>\n<p>\/**<br \/>\n * Removes the contents of the cache key in the group.<br \/>\n *<br \/>\n * &#064;since 2.0.0<br \/>\n *<br \/>\n * &#064;param int|string $key   What the key of the cache to delete.<br \/>\n * &#064;param string     $group Optional. Which group to delete from. Default empty.<br \/>\n *<br \/>\n * &#064;return bool Always returns true.<br \/>\n *\/<br \/>\npublic function delete( $key, $group &#061; &#039;&#039; ) {<br \/>\n    $key   &#061; (string) $key;<br \/>\n    $group &#061; (string) $group;<\/p>\n<p>    unset( $this-&gt;cache[ $group ][ $key ] );<br \/>\n    return true;<br \/>\n}<\/p>\n<p>These functions help manage how the cache is handled, especially in a multisite environment or with persistent caching. add_global_groups ensures certain data is consistent across all sites in a network, while add_non_persistent_groups keeps data separate. reset clears the cache, and delete removes specific items.<\/p>\n<p>Why Use wp_cache_get() and wp_cache_set() Even Without a Persistent Cache?<\/p>\n<p>Even though the internal cache is short-lived, using wp_cache_get() and wp_cache_set() is still beneficial:<\/p>\n<ul>\n<li>Code Consistency: Using these functions prepares your code for easy integration with a persistent object cache later on. You won\u2019t have to rewrite your code to use a different caching API.<\/li>\n<li>Reduced Redundant Operations: Within a single request, you might need the same data multiple times. The internal cache prevents you from performing the same database query or complex calculation repeatedly.<\/li>\n<li>Testing and Debugging: You can easily simulate caching behavior during development and testing.<\/li>\n<\/ul>\n<p>Code Example: Optimizing a Loop<\/p>\n<p>Let\u2019s say you have a loop that needs to retrieve the same post meta data for each post.<\/p>\n<p>\/\/ Without caching<br \/>\n$posts &#061; get_posts( array( &#039;numberposts&#039; &#061;&gt; 10 ) );<br \/>\nforeach ( $posts as $post ) {<br \/>\n    $meta_value &#061; get_post_meta( $post-&gt;ID, &#039;my_custom_field&#039;, true );<br \/>\n    echo $meta_value . &#039;&lt;br&gt;&#039;;<br \/>\n}<\/p>\n<p>\/\/ With caching<br \/>\n$posts &#061; get_posts( array( &#039;numberposts&#039; &#061;&gt; 10 ) );<br \/>\nforeach ( $posts as $post ) {<br \/>\n    $cache_key &#061; &#039;post_meta_&#039; . $post-&gt;ID . &#039;_my_custom_field&#039;;<br \/>\n    $meta_value &#061; wp_cache_get( $cache_key, &#039;my_meta_group&#039; );<\/p>\n<p>    if ( false &#061;&#061;&#061; $meta_value ) {<br \/>\n        $meta_value &#061; get_post_meta( $post-&gt;ID, &#039;my_custom_field&#039;, true );<br \/>\n        wp_cache_set( $cache_key, $meta_value, &#039;my_meta_group&#039; );<br \/>\n    }<\/p>\n<p>    echo $meta_value . &#039;&lt;br&gt;&#039;;<br \/>\n}<\/p>\n<p>In the second example, the get_post_meta() function is only called once per post per request. Subsequent calls retrieve the data from the cache.<\/p>\n<p>When to Consider a Persistent Cache<\/p>\n<p>The internal cache is a good starting point, but for high-traffic sites, a persistent object cache (Memcached, Redis, etc.) is essential. Here\u2019s when you should consider upgrading:<\/p>\n<ul>\n<li>Slow Page Load Times: If your site is consistently slow, especially for logged-in users or dynamic content, a persistent cache can significantly improve performance.<\/li>\n<li>High Database Load: If your database server is under heavy load, caching can reduce the number of database queries.<\/li>\n<li>Scalability: A persistent cache helps your site handle more traffic without requiring more server resources.<\/li>\n<\/ul>\n<p>Troubleshooting<\/p>\n<p>If you\u2019re not seeing the expected caching behavior, here are some things to check:<\/p>\n<ul>\n<li>Typos: Double-check the cache keys and group names in wp_cache_get() and wp_cache_set().<\/li>\n<li>Data Changes: Make sure the data you\u2019re caching isn\u2019t being modified elsewhere in your code.<\/li>\n<li>Object Cloning Issues: If you\u2019re caching objects, ensure that the cloning is working correctly and that you\u2019re not accidentally modifying the original cached object.<\/li>\n<\/ul>\n<p>In Conclusion<\/p>\n<p>While not as powerful as persistent caching solutions, the internal WordPress object cache provides a basic level of caching functionality. Understanding how wp_cache_get() and wp_cache_set() work under the hood is crucial for optimizing your WordPress site\u2019s performance and preparing it for future scalability. Remember, caching is all about reducing redundant operations and serving data more efficiently. Use these functions wisely, and your WordPress site will thank you for it!<\/p>\n<p>Now, go forth and cache all the things! (Responsibly, of course.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb479\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u3010\u4ee3\u7801\u3011\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,1301,190,398],"topic":[],"class_list":["post-54326","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-wordpress","tag-190","tag-398"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/54326.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb479\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u3010\u4ee3\u7801\u3011\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54326.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T18:09:46+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54326.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54326.html\",\"name\":\"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T18:09:46+00:00\",\"dateModified\":\"2025-08-12T18:09:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54326.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54326.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54326.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/54326.html","og_locale":"zh_CN","og_type":"article","og_title":"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb479\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u3010\u4ee3\u7801\u3011\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54326.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T18:09:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54326.html","url":"https:\/\/www.wsisp.com\/helps\/54326.html","name":"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T18:09:46+00:00","dateModified":"2025-08-12T18:09:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54326.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54326.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54326.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u8be6\u89e3 WordPress `wp_cache_get()` \u548c `wp_cache_set()` \u51fd\u6570\u7684\u6e90\u7801\uff1a\u5728\u6ca1\u6709\u5916\u90e8\u7f13\u5b58\u65f6\u7684\u5185\u90e8\u5de5\u4f5c\u673a\u5236\u3002"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=54326"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54326\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54326"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}