mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
torrentrss add cache by sql
This commit is contained in:
@@ -73,7 +73,7 @@ final class MsgAlert {
|
|||||||
public function remove($name): void
|
public function remove($name): void
|
||||||
{
|
{
|
||||||
foreach (self::$alerts as $item) {
|
foreach (self::$alerts as $item) {
|
||||||
if ($item['name'] = $name) {
|
if ($item['name'] == $name) {
|
||||||
unset(self::$alerts[$name]);
|
unset(self::$alerts[$name]);
|
||||||
NexusDB::redis()->lRem($this->getListKey(), json_encode($item));
|
NexusDB::redis()->lRem($this->getListKey(), json_encode($item));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
$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) {
|
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";
|
$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) {
|
if (!empty($prependIdArr) && $startindex == 0) {
|
||||||
$prependIdStr = implode(',', $prependIdArr);
|
$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 = [];
|
$list = [];
|
||||||
foreach ($prependRows as $row) {
|
foreach ($prependRows as $row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user