Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

add option to turn on/off version check #9

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/MemcachedConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public function connect(
);
}
}
// some cloud memcached service don't return correct version, so skip version check.
$checkVersion = in_array("check_version",$options) ? $options["check_version"] : FALSE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No space found after comma in function call
  • TRUE, FALSE and NULL must be lowercase; expected false but found FALSE


return $this->validateConnection($memcached);
return $this->validateConnection($memcached, $checkVersion);
}

/**
Expand Down Expand Up @@ -97,15 +99,15 @@ protected function setCredentials($memcached, $credentials)
* @param \Memcached $memcached
* @return \Memcached
*/
protected function validateConnection($memcached)
protected function validateConnection($memcached, $checkVersion=TRUE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Incorrect spacing between argument $checkVersion and equals sign; expected 1 but found 0
  • Incorrect spacing between default value and equals sign for argument $checkVersion; expected 1 but found 0
  • TRUE, FALSE and NULL must be lowercase; expected true but found TRUE

{
$status = $memcached->getVersion();

if (! is_array($status)) {
throw new RuntimeException('No Memcached servers added.');
}

if (in_array('255.255.255', $status) && count(array_unique($status)) === 1) {
if ($checkVersion && in_array('255.255.255', $status) && count(array_unique($status)) === 1) {
throw new RuntimeException('Could not establish Memcached connection.');
}

Expand Down