cache announce userInfo

This commit is contained in:
xiaomlove
2022-03-19 19:51:23 +08:00
parent 4857b799b8
commit a5ea51de55
9 changed files with 17 additions and 6 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
CACHE_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
+1
View File
@@ -17,6 +17,7 @@ class Platform
*/
public function handle(Request $request, Closure $next)
{
do_log(nexus_json_encode($_SERVER));
if (empty(CURRENT_PLATFORM)) {
throw new \InvalidArgumentException("Require platform header.");
}
+1 -1
View File
@@ -129,7 +129,7 @@ class TagRepository extends BaseRepository
return count($values);
}
public static function getOrderByFieldIdString()
public static function getOrderByFieldIdString(): string
{
if (is_null(self::$orderByFieldIdString)) {
$results = self::createBasicQuery()->get(['id']);
+5 -2
View File
@@ -293,7 +293,9 @@ class TrackerRepository extends BaseRepository
/**
* @var $user User
*/
$user = User::query()->where($field, $value)->first();
$user = Cache::remember("user:$field:$value:" . __METHOD__, 60, function () use ($field, $value) {
return User::query()->where($field, $value)->first();
});
if (!$user) {
throw new TrackerException("Invalid $field: $value.");
}
@@ -846,7 +848,8 @@ class TrackerRepository extends BaseRepository
private function getTorrentByInfoHash($infoHash)
{
return Cache::remember(bin2hex($infoHash), 60, function () use ($infoHash) {
$cacheKey = bin2hex($infoHash) . __METHOD__;
return Cache::remember($cacheKey, 60, function () use ($infoHash) {
$fieldRaw = 'id, owner, sp_state, seeders, leechers, added, banned, hr, visible, last_action, times_completed';
$torrent = Torrent::query()->where('info_hash', $infoHash)->selectRaw($fieldRaw)->first();
do_log("cache miss, from database: " . last_query() . ", and get: " . $torrent->id);
+1
View File
@@ -6,5 +6,6 @@ $rootpath= dirname(__DIR__) . '/';
require_once $rootpath . 'include/constants.php';
require_once $rootpath . 'include/globalfunctions.php';
require_once $rootpath . 'include/functions_announce.php';
require_once $rootpath . 'vendor/autoload.php';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/constants.php';
require $rootpath . 'vendor/autoload.php';
require_once $rootpath . 'vendor/autoload.php';
if (!file_exists($rootpath . '.env')) {
$installScriptRelativePath = 'install/install.php';
$installScriptFile = $rootpath . "public/$installScriptRelativePath";
+3
View File
@@ -2812,6 +2812,9 @@ function base64 ($string, $encode=true) {
function loggedinorreturn($mainpage = false) {
global $CURUSER,$BASEURL;
if (!$CURUSER) {
if (CURRENT_SCRIPT == 'ajax') {
exit(fail('Not login!', $_POST));
}
if ($mainpage)
header("Location: " . get_protocol_prefix() . "$BASEURL/login.php");
else {
+3
View File
@@ -425,6 +425,9 @@ class Install
$this->doLog("[CREATE ENV] key: $key, new value: $value from example.");
$newData[$key] = $value;
}
if ($key == 'CACHE_DRIVER') {
$newData[$key] = 'redis';
}
if ($scene == 'install' || !file_exists($envFile)) {
if ($key == 'APP_ENV') {
$newData[$key] = 'production';
+1 -1
View File
@@ -305,7 +305,7 @@ function print_category_editor($type, $row='')
tr($lang_catmanage['col_name']."<font color=\"red\">*</font>", "<input type=\"text\" name=\"name\" value=\"".htmlspecialchars($name)."\" style=\"width: 300px\" /> " . $lang_catmanage['text_second_icon_name_note'], 1);
tr($lang_catmanage['col_image']."<font color=\"red\">*</font>", "<input type=\"text\" name=\"image\" value=\"".htmlspecialchars($image)."\" style=\"width: 300px\" /><br />" . $lang_catmanage['text_image_note'], 1);
tr($lang_catmanage['text_class_name'], "<input type=\"text\" name=\"class_name\" value=\"".htmlspecialchars($class_name)."\" style=\"width: 300px\" /><br />" . $lang_catmanage['text_class_name_note'], 1);
tr($lang_catmanage['row_selections']."<font color=\"red\">*</font>", torrent_selection(return_type_name('source'), 'source', return_category_db_table_name('source'), $source) . torrent_selection(return_type_name('source'), 'source', return_category_db_table_name('source'), $source) . torrent_selection(return_type_name('medium'), 'medium', return_category_db_table_name('medium'), $medium) . torrent_selection(return_type_name('codec'), 'codec', return_category_db_table_name('codec'), $codec) . torrent_selection(return_type_name('standard'), 'standard', return_category_db_table_name('standard'), $standard) . torrent_selection(return_type_name('processing'), 'processing', return_category_db_table_name('processing'), $processing) . torrent_selection(return_type_name('team'), 'team', return_category_db_table_name('team'), $team) . torrent_selection(return_type_name('audiocodec'), 'audiocodec', return_category_db_table_name('audiocodec'), $audiocodec)."<br />".$lang_catmanage['text_selections_note'], 1);
tr($lang_catmanage['row_selections']."<font color=\"red\">*</font>", torrent_selection(return_type_name('source'), 'source', return_category_db_table_name('source'), $source) . torrent_selection(return_type_name('medium'), 'medium', return_category_db_table_name('medium'), $medium) . torrent_selection(return_type_name('codec'), 'codec', return_category_db_table_name('codec'), $codec) . torrent_selection(return_type_name('standard'), 'standard', return_category_db_table_name('standard'), $standard) . torrent_selection(return_type_name('processing'), 'processing', return_category_db_table_name('processing'), $processing) . torrent_selection(return_type_name('team'), 'team', return_category_db_table_name('team'), $team) . torrent_selection(return_type_name('audiocodec'), 'audiocodec', return_category_db_table_name('audiocodec'), $audiocodec)."<br />".$lang_catmanage['text_selections_note'], 1);
}
elseif ($type=='category')
{