Many object caching backends, such as Memcached and Redis support getting multiple values in a single request. Fetching multiple values in one request often results in much faster performance, as it means less requests on an external object cache. However WordPress core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. only supported getting one cache value at a time with the
wp_cache_get() function. In WordPress 5.5 a new function was added called
wp_cache_get_multiple() with the capability to get multiple cache keys in a single request. The function
wp_cache_get_multiple() accepts an array of keys and fetches multiple cache values from the same group.
There are some existing plugins like Advanced Post Cache, Memcached Redux or Redis Object Cache that have already implemented a function called
wp_cache_get_multi() that serves a similar purpose to
wp_cache_get_multiple(). However this function had a different signature to
wp_cache_get_multiple(), as it is allowed an array of keys and groups to be passed, allowing for any cache key to be fetched. To avoid conflicts with numerous plugins that implement the
wp_cache_get_multi() function, it was decided to change the name of the function to
wp_cache_get_multiple() to stop PHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher errors and developer confusion.
To start using
wp_cache_get_multiple(), creators and maintainers of object caching plugins ( drop-ins ), will need to implement this new function. For plugins that are yet to implement this new function, core will detect that the
wp_cache_get_multiple() function does not exist. If it does not exist, then adds a compatibility shim to add the
wp_cache_get_multiple() function that simply calls
Along with adding this new function, WordPress core has implemented it in the following places.
See implementation Core Trac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. ticket Created for both bug reports and feature development on the bug tracker.: #50352
See full details of the eight year journey to getting this ticket into core can be found in Core Trac #20875.
Props to justinahinon and sergeybiryukov for proofreading.