wp_cache_get_multiple() after upgrading to WP 5.5
-
Cross-posting from https://github.com/rhubarbgroup/redis-cache/issues/243
I have been getting cache misses for wp_cache_get_multiple() after upgrading to WP 5.5.
It seems to be returning false all the time as after priming the cache, it doesn’t read back from the cache.
Setting the cache
[12-Aug-2020 14:19:51 UTC] START wp_cache_add [12-Aug-2020 14:19:51 UTC] {"gamerz_wp:category_relationships:4333":[1461]} [12-Aug-2020 14:19:51 UTC] END wp_cache_add
Using get_multiple to read (notice that it returns false for
gamerz_wp:category_relationships:4333
)[12-Aug-2020 14:20:23 UTC] START get_multiple [12-Aug-2020 14:20:23 UTC] {"derived_keys":{"4285":"gamerz_wp:category_relationships:4285","4293":"gamerz_wp:category_relationships:4293","4324":"gamerz_wp:category_relationships:4324","4325":"gamerz_wp:category_relationships:4325","4333":"gamerz_wp:category_relationships:4333","4337":"gamerz_wp:category_relationships:4337","4340":"gamerz_wp:category_relationships:4340","4344":"gamerz_wp:category_relationships:4344","4348":"gamerz_wp:category_relationships:4348","4349":"gamerz_wp:category_relationships:4349"}} [12-Aug-2020 14:20:23 UTC] {"cache":{"4285":false,"4293":false,"4324":false,"4325":false,"4333":false,"4337":false,"4340":false,"4344":false,"4348":false,"4349":false}} [12-Aug-2020 14:20:23 UTC] END get_multiple
Might be due to the remaining keys
Line 1371 of object-cache.php
$remaining_keys = array_filter( $keys, function ( $key ) use ( $cache ) { return ! isset( $cache[ $key ] ); } );
This change works for me.
$cache[ $key ]
will always be set and be false if the cache fails.$remaining_keys = array_filter( $keys, function ( $key ) use ( $cache ) { return isset( $cache[ $key ] ) && $cache[ $key ] === false; } );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_cache_get_multiple() after upgrading to WP 5.5’ is closed to new replies.