diff --git a/src/Adapter/Memcached.php b/src/Adapter/Memcached.php index 410949b..d23cc58 100644 --- a/src/Adapter/Memcached.php +++ b/src/Adapter/Memcached.php @@ -20,27 +20,18 @@ public function set(string $key, float $value, int $ttl): bool } public function get(string $key): float - { - $ret = $this->realGet($key); - if (is_float($ret)) { - return $ret; - } - throw new \InvalidArgumentException("Unexpected data type from memcache, expected float, got " . gettype($ret)); - } - - private function realGet(string $key): bool|float { $ret = $this->memcached->get($key); - if (is_float($ret) || is_bool($ret)) { - return $ret; + if (is_numeric($ret)) { + return (float) $ret; } - throw new \InvalidArgumentException("Unsupported data type from memcache: " . gettype($ret)); + throw new \InvalidArgumentException("Unexpected data type from memcache, expected float, got " . gettype($ret)); } public function exists(string $key): bool { - $val = $this->realGet($key); - return $val !== false; + $ret = $this->memcached->get($key); + return $ret !== false; } public function del(string $key): bool