首页 > php教程 > php手册 > wp_cache_set和wp_cache_get

wp_cache_set和wp_cache_get

WBOY
发布: 2016-06-13 10:17:37
原创
1325 人浏览过

 

<span function</span> wp_cache_set( <span $key</span>, <span $data</span>, <span $group</span> = '', <span $expire</span> = 0<span  ) {
    </span><span global</span> <span $wp_object_cache</span><span ;
 
    </span><span return</span> <span $wp_object_cache</span>->set( <span $key</span>, <span $data</span>, <span $group</span>, (int) <span $expire</span><span  );
}</span>
登录后复制

<span function</span> wp_cache_get( <span $key</span>, <span $group</span> = '', <span $force</span> = <span false</span>, &<span $found</span> = <span null</span><span  ) {
    </span><span global</span> <span $wp_object_cache</span><span ;
 
    </span><span return</span> <span $wp_object_cache</span>->get( <span $key</span>, <span $group</span>, <span $force</span>, <span $found</span><span  );
}</span>
登录后复制


=->ID,,'related_posts',3600);

<span global</span> <span $post</span><span ;
</span><span $related_posts_data</span> = wp_cache_get(<span $post</span>->ID,'related_posts'<span );
</span><span if</span>(<span false</span> === <span $related_posts_data</span><span ){
    </span><span $related_posts_data</span> =<span  wp_get_related_posts();
    wp_cache_set(</span><span $post</span>->ID,<span $related_posts_data</span>,'related_posts',3600<span );
}
</span><span echo</span> <span $related_posts_data</span>;
登录后复制

 

ID,’related_posts’);

 

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板