[wp-trac] [WordPress Trac] #61296: Add "force" parameter to get_option and get_transient

WordPress Trac noreply at wordpress.org
Thu Sep 5 19:57:17 UTC 2024


#61296: Add "force" parameter to get_option and get_transient
-----------------------------------------+------------------------------
 Reporter:  juvodesign                   |       Owner:  (none)
     Type:  enhancement                  |      Status:  reopened
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Options, Meta APIs           |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------

Comment (by alexeykorotkov):

 Replying to [comment:7 azaozz]:

 > Could you explain the use case(s) for it?

 Not the OP, but I can chime in.

 The database is the sole source of truth, while cache is not reliable: it
 may get unintentionally flushed by something else, causing time-of-check
 /time-of-use issues that in some cases may build up to undefined behavior.

 Usually it's not a big concern, but sometimes it is:
  - handling locks (OP's example)
  - doing many operations in a loop on a list of transient items: the
 operations may trigger hooks that flush the cache for the items the loop
 iterates over

 This way, developers would have an option to ensure the data is as correct
 as possible, at the cost of the option/transient read speed.

 > Also thinking there may be a chances to run into some DB write/read
 problems for options that have been just set, especially when the DB is
 replicated?

 Database changes that do not propagate immediately is not really something
 that can be supported anyways. Not to mention that the cache is not
 something that is present everywhere, so if there were issues with that,
 they would have already surfaced in cache-less installs.

 In normal HA setups, the replication delay does not affect the master's
 ability to mutate the state immediately.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61296#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list