torrentrss add cache by sql

This commit is contained in:
xiaomlove
2025-09-21 00:34:41 +07:00
parent 409b734d3a
commit d16a864841
2 changed files with 8 additions and 3 deletions

View File

@@ -73,7 +73,7 @@ final class MsgAlert {
public function remove($name): void
{
foreach (self::$alerts as $item) {
if ($item['name'] = $name) {
if ($item['name'] == $name) {
unset(self::$alerts[$name]);
NexusDB::redis()->lRem($this->getListKey(), json_encode($item));
}

View File

@@ -178,11 +178,16 @@ $sort = "id desc";
$fieldStr = "torrents.id, torrents.category, torrents.name, torrents.small_descr, torrent_extras.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, torrents.owner, categories.name AS category_name";
if (!$noNormalResults) {
$query = "SELECT $fieldStr FROM torrents LEFT JOIN categories ON torrents.category = categories.id left join torrent_extras on torrent_extras.torrent_id = torrents.id $normalWhere ORDER BY $sort LIMIT $limit";
$normalRows = \Nexus\Database\NexusDB::select($query);
$normalRows = \Nexus\Database\NexusDB::remember(sprintf("nexus_rss:normal:%s", md5($query)), 300, function () use ($query) {
return \Nexus\Database\NexusDB::select($query);
});
}
if (!empty($prependIdArr) && $startindex == 0) {
$prependIdStr = implode(',', $prependIdArr);
$prependRows = \Nexus\Database\NexusDB::select("SELECT $fieldStr FROM torrents LEFT JOIN categories ON torrents.category = categories.id left join torrent_extras on torrent_extras.torrent_id = torrents.id where torrents.id in ($prependIdStr) and $where ORDER BY field(torrents.id, $prependIdStr)");
$query = "SELECT $fieldStr FROM torrents LEFT JOIN categories ON torrents.category = categories.id left join torrent_extras on torrent_extras.torrent_id = torrents.id where torrents.id in ($prependIdStr) and $where ORDER BY field(torrents.id, $prependIdStr)";
$prependRows = \Nexus\Database\NexusDB::remember(sprintf("nexus_rss:prepend:%s", md5($query)), 300, function () use ($query) {
return \Nexus\Database\NexusDB::select($query);
});
}
$list = [];
foreach ($prependRows as $row) {