diff --git a/README.md b/README.md index d874238..0645194 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ $SimpleCache = new \Rundiz\SimpleCache\Drivers\Apcu(); $SimpleCache = new \Rundiz\SimpleCache\Drivers\FileSystem(); ``` -Common methods to get, set, delete, or anything else please read more at [PSR-16 doc.](https://www.php-fig.org/psr/psr-16/).
+Common methods to get, set, delete, or anything else please read more at [PSR-16 document](https://www.php-fig.org/psr/psr-16/).
Here are few examples. ```php diff --git a/src/Drivers/Memcached.php b/src/Drivers/Memcached.php index 5099560..ae10149 100644 --- a/src/Drivers/Memcached.php +++ b/src/Drivers/Memcached.php @@ -65,12 +65,12 @@ public function get($key, $default = null) throw new InvalidArgumentException('$key must be a string'); } - $flags = false; - $value = $this->Memcached->get($key, $flags); - if ($flags !== false) { - return $value; + $result = $this->Memcached->get($key); + if ($result === false && $this->Memcached->getResultCode() === \Memcached::RES_NOTFOUND) { + return $default; } - return $default; + + return $result; }// get diff --git a/tests/phpunit/MemcachedTest.php b/tests/phpunit/MemcachedTest.php index c625930..700792c 100644 --- a/tests/phpunit/MemcachedTest.php +++ b/tests/phpunit/MemcachedTest.php @@ -24,7 +24,7 @@ public function setup() } $Memcached = new \Memcached; - $Memcached->connect('localhost', 11211) or die ("Could not connect"); + $Memcached->addServer('localhost', 11211) or die ("Could not connect"); $this->SimpleCache = new \Rundiz\SimpleCache\Drivers\Memcached($Memcached); }// setup @@ -32,7 +32,7 @@ public function setup() public function tearDown() { $this->SimpleCache->clear(); - $this->SimpleCache->getMemcached()->close(); + $this->SimpleCache->getMemcached()->quit(); }// tearDown diff --git a/tests/via-http/memcached.php b/tests/via-http/memcached.php index 9ad4e4c..f7b0da4 100644 --- a/tests/via-http/memcached.php +++ b/tests/via-http/memcached.php @@ -3,7 +3,7 @@ $Memcached = new \Memcached; -$Memcached->connect('localhost', 11211) or die ("Could not connect"); +$Memcached->addServer('localhost', 11211) or die ("Could not connect"); $SimpleCache = new Rundiz\SimpleCache\Drivers\Memcached($Memcached); if (isset($_GET['act']) && $_GET['act'] === 'clear') {