1
JSONファイルをフェッチしてサーバーにキャッシュする最良の方法は何ですか?私は、リモートソースからのJSONファイルを取得し、(24時間など)、それをキャッシュしたいので、以下のインターネット容量をコスト:)JSONファイルのフェッチとキャッシュ
class Json {
public $url;
public $hash;
public function LoadJson($url) {
// Exist function
if (file_exists($hash)) {
// Load md5 file
return $hash;
} else {
$json_file = file_get_contents($url);
$jfo = json_decode($json_file);
// Save json file on server
// Convert url to md5
}
}
}
$MyJson = new Json;
$MyJson->LoadJson('http://google.com/file.json');