public function has(string $key): bool
    {
        if (array_key_exists($key, $this->ttl) &&
            $this->time() - $this->ttl[$key] > 0
        ) {
            unset($this->ttl[$key]);
            unset($this->storage[$key]);

            return false;
        }

        return array_key_exists($key, $this->storage);
    }
public function has(string $key): bool
    {
        if (array_key_exists($key, $this->ttl) &&
            $this->time() - $this->ttl[$key] > 0
        ) {
            unset($this->ttl[$key]);
            unset($this->storage[$key]);

            return false;
        }

        return array_key_exists($key, $this->storage);
    }
public function has ( string $ key ) : bool { if ( array_key_exists ( $ key , $ this -> ttl ) && $ this -> time ( ) - $ this -> ttl [ $ key ] > 0 ) { unset ( $ this -> ttl [ $ key ] ) ; unset ( $ this -> storage [ $ key ] ) ; return false ; } return array_key_exists ( $ key , $ this -> storage ) ; }
Determine if an item exists in the cache. This method will also check
if the ttl of the given cache key has been expired and will free the
memory if so.

@param string $key cache key of the item

@return bool has cache key
Determine if an item exists in the cache . This method will also check if the ttl of the given cache key has been expired and will free the memory if so .