public function fetch($key)
    {
        if (!$this->getConnection()->exists($key)) {
            return [];
        }

        $type = $this->getConnection()->type($key)->__toString();

        /** @var DataType $class */
        $class = $this->{$type}();

        $value = $class->fetch($key);
        $ttl = $class->ttl($key);

        return compact('key', 'value', 'ttl', 'type');
    }
public function fetch($key)
    {
        if (!$this->getConnection()->exists($key)) {
            return [];
        }

        $type = $this->getConnection()->type($key)->__toString();

        /** @var DataType $class */
        $class = $this->{$type}();

        $value = $class->fetch($key);
        $ttl = $class->ttl($key);

        return compact('key', 'value', 'ttl', 'type');
    }
public function fetch ( $ key ) { if ( ! $ this -> getConnection ( ) -> exists ( $ key ) ) { return [ ] ; } $ type = $ this -> getConnection ( ) -> type ( $ key ) -> __toString ( ) ; /** @var DataType $class */ $ class = $ this -> { $ type } ( ) ; $ value = $ class -> fetch ( $ key ) ; $ ttl = $ class -> ttl ( $ key ) ; return compact ( 'key' , 'value' , 'ttl' , 'type' ) ; }
Fetch value of a giving key.

@param string $key

@return array
Fetch value of a giving key .