SimplePie_Cache::create PHP Method

create() public method

Create a new SimplePie_Cache object
public create ( $location, $filename, $extension )
    function create($location, $filename, $extension)
    {
        $location_iri = new SimplePie_IRI($location);
        switch ($location_iri->get_scheme()) {
            case 'mysql':
                if (extension_loaded('mysql')) {
                    return new SimplePie_Cache_MySQL($location_iri, $filename, $extension);
                }
                break;
            default:
                return new SimplePie_Cache_File($location, $filename, $extension);
        }
    }

Usage Example

Exemplo n.º 1
0
function display_cached_file($identifier_url, $cache_location = './cache')
{
    $cache = SimplePie_Cache::create($cache_location, $identifier_url, 'spi');
    if ($file = $cache->load()) {
        if (isset($file['headers']['content-type'])) {
            header('Content-type:' . $file['headers']['content-type']);
        } else {
            header('Content-type: application/octet-stream');
        }
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT');
        // 7 days
        echo $file['body'];
        exit;
    }
    die('Cached file for ' . $identifier_url . ' cannot be found.');
}