-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confirm memcached is giving the correct response #69
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset
is not reliable in this context because it'll be false
if the value is NULL
:
$keys = [
'test' => null,
'test2' => 'null',
'test3' => 1,
];
foreach( $keys as $key => $val ) {
var_dump( isset( $keys[ $key ] ) );
}
echo "\n";
foreach( $keys as $key => $val ) {
var_dump(array_key_exists( $key , $keys ) );
}
=>
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
array_key_exists
would be safer.
Documenting some of the edge-case behaviors:
|
The PR is a bit more complex now though, but some good news is that we can eventually deploy to Side note: Held off on using PHP's new array destructuring & |
Slight performance boost under optimal conditions.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
If you send an array, the memcache client will respond with an associative array: https://www.php.net/manual/en/memcache.get.php. With this, we can ensure that the memcached server is giving us the correct response.
This is just a proof of concept for now. Some further ideas include:
As a side note, we should really be making use of this functionality for the multi_get() logic that WP now uses - as it can greatly limit the # of roundtrips to the memcached server. But can come back to that another day :).