public function get($cid, $options = array())
    {
        $options += array(
            'lifespan' => 0,
            'default' => null
        );

        $result = null;
        $this->hook->attach('cache.get.before', $cid, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        if (is_array($cid)) {
            $cid = gplcart_array_hash($cid);
        }

        $this->file = GC_DIR_CACHE . "/$cid.cache";

        $result = $options['default'];

        if (is_file($this->file)) {

            $this->filemtime = filemtime($this->file);

            if (empty($options['lifespan']) || ((GC_TIME - $this->filemtime) < $options['lifespan'])) {
                $result = unserialize(file_get_contents($this->file));
            }
        }

        $this->hook->attach('cache.get.after', $cid, $options, $result, $this);
        return $result;
    }
public function get($cid, $options = array())
    {
        $options += array(
            'lifespan' => 0,
            'default' => null
        );

        $result = null;
        $this->hook->attach('cache.get.before', $cid, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        if (is_array($cid)) {
            $cid = gplcart_array_hash($cid);
        }

        $this->file = GC_DIR_CACHE . "/$cid.cache";

        $result = $options['default'];

        if (is_file($this->file)) {

            $this->filemtime = filemtime($this->file);

            if (empty($options['lifespan']) || ((GC_TIME - $this->filemtime) < $options['lifespan'])) {
                $result = unserialize(file_get_contents($this->file));
            }
        }

        $this->hook->attach('cache.get.after', $cid, $options, $result, $this);
        return $result;
    }
public function get ( $ cid , $ options = array ( ) ) { $ options += array ( 'lifespan' => 0 , 'default' => null ) ; $ result = null ; $ this -> hook -> attach ( 'cache.get.before' , $ cid , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } if ( is_array ( $ cid ) ) { $ cid = gplcart_array_hash ( $ cid ) ; } $ this -> file = GC_DIR_CACHE . "/$cid.cache" ; $ result = $ options [ 'default' ] ; if ( is_file ( $ this -> file ) ) { $ this -> filemtime = filemtime ( $ this -> file ) ; if ( empty ( $ options [ 'lifespan' ] ) || ( ( GC_TIME - $ this -> filemtime ) < $ options [ 'lifespan' ] ) ) { $ result = unserialize ( file_get_contents ( $ this -> file ) ) ; } } $ this -> hook -> attach ( 'cache.get.after' , $ cid , $ options , $ result , $ this ) ; return $ result ; }
Returns a cached data
@param string|array $cid
@param array $options
@return mixed
Returns a cached data