static public function exists($key)
    {
        $keyMD5 = md5(self::$keyPrefix . serialize($key));
        $dir = self::getLocksDir();
        if (!is_dir($dir)) {
            return false;
        }
        $filename = $dir . $keyMD5 . '.lock';
        set_error_handler(function($errno, $errstr) {
            throw new \Exception($errstr);
        });
        try {
            $filePointer = fopen($filename, "w");
            if ($filePointer !== false) {
                $wouldBlock = null;
                if (flock($filePointer, LOCK_EX | LOCK_NB, $wouldBlock)) {
                    restore_error_handler();
                    return false;
                } else {
                    restore_error_handler();
                    return $wouldBlock === 1;
                }
            }
        } catch (\Exception $e) {
            
        }
        restore_error_handler();
        throw new \Exception('Cannot check if lock named "' . $key . '" exists.');
    }