wp_cache_set和wp_cache_get_PHP教程

WBOY
Lepaskan: 2016-07-13 17:17:06
asal
1050 orang telah melayarinya

 

<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>
Salin selepas log masuk

<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>
Salin selepas log masuk


=->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>;
Salin selepas log masuk

 

ID,’related_posts’);

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/626629.htmlTechArticlewp_cache_set( , , = '', = 0 -gt;set( , , , (int) wp_cache_get( , = '', = , amp; = -gt;get( , , , = -gt;ID, ,'related_posts',3600); = wp_cache_get( -gt;ID,'related_posts' ( === = -g...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan