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
+1
View File
@@ -1136,6 +1136,7 @@ function clear_user_cache($uid, $passkey = '')
\Nexus\Database\NexusDB::cache_del("direct_permissions:$uid"); \Nexus\Database\NexusDB::cache_del("direct_permissions:$uid");
if ($passkey) { if ($passkey) {
\Nexus\Database\NexusDB::cache_del('user_passkey_'.$passkey.'_content');//announce.php \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); $userInfo = \App\Models\User::query()->find($uid, \App\Models\User::$commonFields);
if ($userInfo) { if ($userInfo) {
+5 -3
View File
@@ -11,7 +11,7 @@ if ($cacheData && nexus_env('APP_ENV') != 'local') {
header ("Content-type: text/xml"); header ("Content-type: text/xml");
die($cacheData); die($cacheData);
} }
dbconn(); dbconn(doLogin: false);
function hex_esc($matches) { function hex_esc($matches) {
return sprintf("%02x", ord($matches[0])); return sprintf("%02x", ord($matches[0]));
} }
@@ -19,8 +19,10 @@ $dllink = false;
$where = ""; $where = "";
if ($passkey){ if ($passkey){
$res = sql_query("SELECT id, enabled, parked, passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); $user = \Nexus\Database\NexusDB::remember('user_passkey_'.$passkey.'_rss', 3600, function () use ($passkey) {
$user = mysql_fetch_array($res); $res = sql_query("SELECT id, enabled, parked, passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
return mysql_fetch_array($res);
});
if (!$user) if (!$user)
die("invalid passkey"); die("invalid passkey");
elseif ($user['enabled'] == 'no' || $user['parked'] == 'yes') elseif ($user['enabled'] == 'no' || $user['parked'] == 'yes')