[wp-trac] [WordPress Trac] #43112: set_transient uses object-cache as storage instead of cache layer
WordPress Trac
noreply at wordpress.org
Wed Jan 17 20:47:49 UTC 2018
#43112: set_transient uses object-cache as storage instead of cache layer
-------------------------+------------------------------
Reporter: batooo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cache API | Version: 4.9.1
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by batooo):
Not a solution as you said, "Disadvantage is that you can use that only in
your own code for your own caches, other transients will still be saved in
object cache only.".
About slow loading or high CPU, imagine 10 external API requests each time
PHP is restarted or imagine doing some CPU intense job each time PHP is
restarted instead of every 24 hours.
What`s the point of using object-cache as storage when transient was
designed becouse of extra element "expire time"?
Replying to [comment:1 dimadin]:
> If you want to have “persistent” transients, than there are libraries
that you can use to save temporary data in database instead of in object
cache. For example, my own [https://github.com/dimadin/wp-temporary
WP_Temporary], or newly released [https://github.com/10up/Async-Transients
Async Transients].
>
> In case of `WP_Temporary`, you would use `WP_Temporary::set( $transient,
$value, $expiration );` instead of `set_transient( $transient, $value,
$expiration );`. Advantage here is that even if object cache is purged for
whatever reason, your data is still available from database until it
expires. Disadvantage is that you can use that only in your own code for
your own caches, other transients will still be saved in object cache
only. You can code workaround to force that data in database too, but I am
not sure will it degrade performance for some cases.
>
> > Using APCu as an object-cache which is a PHP in-process storage leads
to high CPU and very slow loading time.
>
> I am not sure what you want to say with this, but note that when you
turn on object caching, many other data is stored there, not just
transients, post objects, taxonomy terms, comments, users, queries etc.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43112#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list