8000 Using file cache for tokens. · etherscan-io/Ethplorer@d9e02c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d9e02c9

Browse files
committed
Using file cache for tokens.
1 parent 21e0e8d commit d9e02c9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

service/lib/ethplorer.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,8 @@ public function getTokens($updateCache = false){
11291129
$tokensFileCache = '<?php'. "\n" . 'return ';
11301130
$tokensFileCache .= $this->varExportMin($aResult);
11311131
$tokensFileCache .= ';' . "\n";
1132-
file_put_contents(dirname(__FILE__) . self::TOKENS_FILE_CACHE, $tokensFileCache);
1132+
$this->saveFile(dirname(__FILE__) . self::TOKENS_FILE_CACHE, $tokensFileCache);
1133+
$this->_cliDebug("Tokens file cache saved.");
11331134
}
11341135

11351136
evxProfiler::checkpoint('getTokens', 'FINISH');
@@ -3647,6 +3648,14 @@ protected function varExportMin($input){
36473648
}
36483649
}
36493650

3651+
protected function saveFile($file, $content){
3652+
$res = FALSE;
3653+
if(FALSE !== file_put_contents($file . '.tmp', $content)){
3654+
$res = rename($file . '.tmp', $file);
3655+
}
3656+
return $res;
3657+
}
3658+
36503659
protected function log($file, $message, $log = true){
36513660
if($log){
36523661
@file_put_contents(__DIR__ . '/../log/' . $file . '.log', '[' . date('Y-m-d H:i:s') . "] " . $message . "\n", FILE_APPEND);

0 commit comments

Comments
 (0)
0