public static function expiration(string $key, ?string $storage = 'global'): ?int
    {
        if (!self::has($key)) {
            return null;
        }

        // Get content.
        $fileKey = self::key($key);
        $content = null;
        if (file_exists(self::$path . '/' . $storage . '/' . $fileKey)) {
            $content = file_get_contents(self::$path . '/' . $storage . '/' . $fileKey);
        }

        // Extract expiration.
        $markerPos = strpos($content, self::$marker);
        $expiration = null;
        if ($markerPos !== false) {
            $expiration = intval(substr($content, 0, $markerPos));
        }

        return $expiration;
    }
public static function expiration(string $key, ?string $storage = 'global'): ?int
    {
        if (!self::has($key)) {
            return null;
        }

        // Get content.
        $fileKey = self::key($key);
        $content = null;
        if (file_exists(self::$path . '/' . $storage . '/' . $fileKey)) {
            $content = file_get_contents(self::$path . '/' . $storage . '/' . $fileKey);
        }

        // Extract expiration.
        $markerPos = strpos($content, self::$marker);
        $expiration = null;
        if ($markerPos !== false) {
            $expiration = intval(substr($content, 0, $markerPos));
        }

        return $expiration;
    }
public static function expiration ( string $ key , ? string $ storage = 'global' ) : ? int { if ( ! self :: has ( $ key ) ) { return null ; } // Get content. $ fileKey = self :: key ( $ key ) ; $ content = null ; if ( file_exists ( self :: $ path . '/' . $ storage . '/' . $ fileKey ) ) { $ content = file_get_contents ( self :: $ path . '/' . $ storage . '/' . $ fileKey ) ; } // Extract expiration. $ markerPos = strpos ( $ content , self :: $ marker ) ; $ expiration = null ; if ( $ markerPos !== false ) { $ expiration = intval ( substr ( $ content , 0 , $ markerPos ) ) ; } return $ expiration ; }
Get expiration from key.

@param string $key
@param string $storage Default 'global'.
@return int If not set, null is returned.
Get expiration from key .