protected static function get_cache($fn, $expire = false, $meta_only = false)
    {
        $meta = $cnt = null;
        if (file_exists($fn) and $fm = filemtime($fn) and (!$expire || $fm + $expire > time())) {
            $cnt = self::flock_get_contents($fn);
        }
        $t = strlen($cnt);
        if (!empty($cnt)) {
            if ($gz = !strncmp($cnt, "\x1F\x8B", 2)) {
                $cnt = self::gzdecode($cnt);
            }
            if ('#' == $cnt[0]) {
                $n = (int) substr($cnt, 1, 0x10);
                $l = strlen($n) + 2;
                if ($n) {
                    $meta = substr($cnt, $l, $n);
                    if ('' !== $meta) {
                        $meta = self::unjsonize($meta);
                    }

                }
                if ($meta_only) {
                    $cnt = '';
                } else {
                    $l += $n;
                    if ("\n" == $cnt[$l]) {
                        $cnt = substr($cnt, ++$l);
                        if ('' !== $cnt) {
                            $cnt = self::unjsonize($cnt);
                        }

                    } else {
                        $cnt = substr($cnt, $l);
                    }
                }
            } else {
                if ($meta_only) {
                    $cnt = '';
                }

            }
        }
        return $cnt || $meta ? array($cnt, $meta) : false;
    }
protected static function get_cache($fn, $expire = false, $meta_only = false)
    {
        $meta = $cnt = null;
        if (file_exists($fn) and $fm = filemtime($fn) and (!$expire || $fm + $expire > time())) {
            $cnt = self::flock_get_contents($fn);
        }
        $t = strlen($cnt);
        if (!empty($cnt)) {
            if ($gz = !strncmp($cnt, "\x1F\x8B", 2)) {
                $cnt = self::gzdecode($cnt);
            }
            if ('#' == $cnt[0]) {
                $n = (int) substr($cnt, 1, 0x10);
                $l = strlen($n) + 2;
                if ($n) {
                    $meta = substr($cnt, $l, $n);
                    if ('' !== $meta) {
                        $meta = self::unjsonize($meta);
                    }

                }
                if ($meta_only) {
                    $cnt = '';
                } else {
                    $l += $n;
                    if ("\n" == $cnt[$l]) {
                        $cnt = substr($cnt, ++$l);
                        if ('' !== $cnt) {
                            $cnt = self::unjsonize($cnt);
                        }

                    } else {
                        $cnt = substr($cnt, $l);
                    }
                }
            } else {
                if ($meta_only) {
                    $cnt = '';
                }

            }
        }
        return $cnt || $meta ? array($cnt, $meta) : false;
    }
protected static function get_cache ( $ fn , $ expire = false , $ meta_only = false ) { $ meta = $ cnt = null ; if ( file_exists ( $ fn ) and $ fm = filemtime ( $ fn ) and ( ! $ expire || $ fm + $ expire > time ( ) ) ) { $ cnt = self :: flock_get_contents ( $ fn ) ; } $ t = strlen ( $ cnt ) ; if ( ! empty ( $ cnt ) ) { if ( $ gz = ! strncmp ( $ cnt , "\x1F\x8B" , 2 ) ) { $ cnt = self :: gzdecode ( $ cnt ) ; } if ( '#' == $ cnt [ 0 ] ) { $ n = ( int ) substr ( $ cnt , 1 , 0x10 ) ; $ l = strlen ( $ n ) + 2 ; if ( $ n ) { $ meta = substr ( $ cnt , $ l , $ n ) ; if ( '' !== $ meta ) { $ meta = self :: unjsonize ( $ meta ) ; } } if ( $ meta_only ) { $ cnt = '' ; } else { $ l += $ n ; if ( "\n" == $ cnt [ $ l ] ) { $ cnt = substr ( $ cnt , ++ $ l ) ; if ( '' !== $ cnt ) { $ cnt = self :: unjsonize ( $ cnt ) ; } } else { $ cnt = substr ( $ cnt , $ l ) ; } } } else { if ( $ meta_only ) { $ cnt = '' ; } } } return $ cnt || $ meta ? array ( $ cnt , $ meta ) : false ; }
Read data from a cache file.

@param  string $fn        - cache filename
@param  int    $expire    - OPTIONAL contents returned only if it is newer then $expire seconds
@param  bool   $meta_only - OPTIONAL if TRUE, read only meta-info (faster)
@return array  [mixed <contents>, array <meta_info>]
Read data from a cache file .