admin管理员组文章数量:1290135
I understand that Transients API is used to cache data and should be intended to store data that is expected to expire.
However, please clarify the following.
Can set_transient()
be used to store data in multi-site scenario? If yes, how is it different from using set_site_transient()
function?
I understand that Transients API is used to cache data and should be intended to store data that is expected to expire.
However, please clarify the following.
Can set_transient()
be used to store data in multi-site scenario? If yes, how is it different from using set_site_transient()
function?
1 Answer
Reset to default 4As the Codex suggests:
Essentially the same as set_transient() but works network wide when using WP Multisite.
One difference is that the transient name should be 40 characters or less in length. Also, while set_transient() sets transients that have an expiration time to not autoload, all transients added with
set_site_transient
will auto-load at all times.
In other words, the fundamental difference is in the auto-loading and since transients might be serialized, you could risk breaking things if referring to a blog (in MU) which has different settings/url/etc.
So the short answer is:
use set_transient for single blogs
use set_site_transient when you need something for ALL blogs.
Example of stored transients:
本文标签: multisiteCan settransient() be used in multisite
版权声明:本文标题:multisite - Can set_transient() be used in multi-site? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741491990a2381663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论