예제 #1
0
파일: delete.php 프로젝트: jdunck/genetify
function delete_cache($domain, $page)
{
    $filepath = get_cache_pathname($domain, $page);
    if (file_exists($filepath)) {
        unlink($filepath);
    }
}
예제 #2
0
function set_cache($domain, $page)
{
    global $base_url;
    $callback = 'genetify.handleResults';
    $reader_response = file_get_contents("{$base_url}/reader.php?callback={$callback}&domain={$domain}&page={$page}");
    if (!strstr($reader_response, $callback)) {
        errback('Read failure: ' . $reader_response);
    }
    $filepath = get_cache_pathname($domain, $page);
    //TODO: atomic file replace
    $fh = fopen($filepath, 'w');
    $success = fwrite($fh, $reader_response);
    fclose($fh);
    if (!$success) {
        errback('Write failure: ' . $filepath);
    }
}