Skip to content

Commit

Permalink
Update MemcachedConnector.php
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkitjalan committed Sep 9, 2015
1 parent 4ed6bbe commit c22c21c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/MemcachedConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Clowdy\Cache;

use Illuminate\Cache\MemcachedConnector as IlluminateMemcachedConnector;
use RuntimeException;

class MemcachedConnector extends IlluminateMemcachedConnector
{
Expand All @@ -21,8 +22,8 @@ public function connect(array $config)

// Check and set Elasticache options here
if (array_get($config, 'elasticache', false)) {
if (defined('\Memcached::OPT_CLIENT_MODE') && defined('\Memcached::DYNAMIC_CLIENT_MODE')) {
$memcached->setOption(\Memcached::OPT_CLIENT_MODE, \Memcached::DYNAMIC_CLIENT_MODE);
if (defined(get_class($memcached).'::OPT_CLIENT_MODE') && defined(get_class($memcached).'::DYNAMIC_CLIENT_MODE')) {
$memcached->setOption(constant(get_class($memcached).'::OPT_CLIENT_MODE'), constant(get_class($memcached).'::DYNAMIC_CLIENT_MODE'));
}
}

Expand All @@ -39,7 +40,7 @@ public function connect(array $config)
}

if ($memcached->getVersion() === false) {
throw new \RuntimeException('Could not establish Memcached connection.');
throw new RuntimeException('Could not establish Memcached connection.');
}

return $memcached;
Expand Down

0 comments on commit c22c21c

Please sign in to comment.