Make WordPress Core

Opened 2 years ago

Last modified 15 months ago

#56060 new enhancement

Implement wp_cache_replace_multiple() – and related WP_Object_Cache method

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Cache API Keywords: 2nd-opinion needs-patch
Focuses: performance Cc:

Description

See: #20875, #54574.

See also: https://github.com/WordPress/wordpress-develop/pull/2018#discussion_r799643985

🫠

I would like to replace multiple values in a cache, but not add or set them if they do not exist.

In my experience and understanding, replace() doesn't get much love because _exists() may be impossible to implement in certain backends – specifically (or especially) when $group is empty.

My current situation is essentially juggling multiple backends, and only wanting to replace multiple values if they exist on one server and not add or set them until some other unrelated things happen.

I went to call wp_cache_replace_multiple() and thought my IDE had deceived me when it wasn't autocompleting. Alas! Alas, I say!

I can handle this In my own drop-in, and I can account for it in my own codes, but I think perhaps it's worth reconsidering this in core for the sake of parity with everything else.

Thoughts?

Change History (3)

#1 @spacedmonkey
15 months ago

@tillkruess You interested in this one?

#2 @spacedmonkey
15 months ago

  • Milestone changed from Awaiting Review to Future Release

#3 @tillkruess
15 months ago

Would this function set keys that don't exist, or none if even one of the keys exists?

Note: See TracTickets for help on using tickets.