cache rss user content

This commit is contained in:
NekoCH
2023-05-29 19:55:51 +08:00
parent b59377ab47
commit 8a4538faea
2 changed files with 6 additions and 3 deletions

View File

@@ -1136,6 +1136,7 @@ function clear_user_cache($uid, $passkey = '')
\Nexus\Database\NexusDB::cache_del("direct_permissions:$uid");
if ($passkey) {
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_content');//announce.php
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_rss');//torrentrss.php
}
$userInfo = \App\Models\User::query()->find($uid, \App\Models\User::$commonFields);
if ($userInfo) {

View File

@@ -11,7 +11,7 @@ if ($cacheData && nexus_env('APP_ENV') != 'local') {
header ("Content-type: text/xml");
die($cacheData);
}
dbconn();
dbconn(doLogin: false);
function hex_esc($matches) {
return sprintf("%02x", ord($matches[0]));
}
@@ -19,8 +19,10 @@ $dllink = false;
$where = "";
if ($passkey){
$res = sql_query("SELECT id, enabled, parked, passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
$user = mysql_fetch_array($res);
$user = \Nexus\Database\NexusDB::remember('user_passkey_'.$passkey.'_rss', 3600, function () use ($passkey) {
$res = sql_query("SELECT id, enabled, parked, passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
return mysql_fetch_array($res);
});
if (!$user)
die("invalid passkey");
elseif ($user['enabled'] == 'no' || $user['parked'] == 'yes')