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
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ protected function createMemcachedDriver(array $config)
// Extract Plus features from config
$persistentConnectionId = array_get($config, 'persistent_id');
$customOptions = array_get($config, 'options', []);
$checkVersion = array_get($config, 'check_version', true);
$saslCredentials = array_filter(array_get($config, 'sasl', []));

$memcached = $this->app['memcached.connector']->connect(
$config['servers'],
$persistentConnectionId,
$customOptions,
$saslCredentials
$saslCredentials,
$checkVersion
);

return $this->repository(new MemcachedStore($memcached, $prefix));
Expand Down
9 changes: 5 additions & 4 deletions src/MemcachedConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class MemcachedConnector
*/
public function connect(
array $servers, $connectionId = null,
array $options = [], array $credentials = []
array $options = [], array $credentials = [],

Choose a reason for hiding this comment

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

Multi-line function declarations must define one parameter per line

$checkVersion = true
) {
$memcached = $this->getMemcached(
$connectionId, $credentials, $options
Expand All @@ -38,7 +39,7 @@ public function connect(
}
}

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

/**
Expand Down Expand Up @@ -97,15 +98,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

{
$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