cache 30m, refresh token 7d

pull/31/head^2
qkqpttgf 2020-03-11 14:05:21 +08:00 committed by GitHub
parent be51285dca
commit 4630971e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -91,7 +91,7 @@ function getcache($str)
return $cache->fetch($str); return $cache->fetch($str);
} }
function savecache($key, $value, $exp = 3300) function savecache($key, $value, $exp = 1800)
{ {
$cache = null; $cache = null;
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']); $cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
@ -566,7 +566,7 @@ function main($path)
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
$_SERVER['access_token'] = $ret['access_token']; $_SERVER['access_token'] = $ret['access_token'];
savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300); savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300);
if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+30*24*60*60 ]); if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]);
} }
$_SERVER['retry'] = 0; $_SERVER['retry'] = 0;