diff --git a/.env.example b/.env.example
index 51a3e1a7..6becda6c 100644
--- a/.env.example
+++ b/.env.example
@@ -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
diff --git a/app/Http/Middleware/Platform.php b/app/Http/Middleware/Platform.php
index 03f65da7..56e1c2d7 100644
--- a/app/Http/Middleware/Platform.php
+++ b/app/Http/Middleware/Platform.php
@@ -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.");
}
diff --git a/app/Repositories/TagRepository.php b/app/Repositories/TagRepository.php
index 5d10d9c8..2109bc74 100644
--- a/app/Repositories/TagRepository.php
+++ b/app/Repositories/TagRepository.php
@@ -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']);
diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php
index c4d7497d..1bc4c8c5 100644
--- a/app/Repositories/TrackerRepository.php
+++ b/app/Repositories/TrackerRepository.php
@@ -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);
diff --git a/include/bittorrent_announce.php b/include/bittorrent_announce.php
index 4e93c4c8..333a609f 100644
--- a/include/bittorrent_announce.php
+++ b/include/bittorrent_announce.php
@@ -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';
diff --git a/include/core.php b/include/core.php
index 69bdc106..592d7214 100644
--- a/include/core.php
+++ b/include/core.php
@@ -1,6 +1,6 @@
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';
diff --git a/public/catmanage.php b/public/catmanage.php
index e98ef70d..f2263d8d 100644
--- a/public/catmanage.php
+++ b/public/catmanage.php
@@ -305,7 +305,7 @@ function print_category_editor($type, $row='')
tr($lang_catmanage['col_name']."*", " " . $lang_catmanage['text_second_icon_name_note'], 1);
tr($lang_catmanage['col_image']."*", "
" . $lang_catmanage['text_image_note'], 1);
tr($lang_catmanage['text_class_name'], "
" . $lang_catmanage['text_class_name_note'], 1);
- tr($lang_catmanage['row_selections']."*", 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)."
".$lang_catmanage['text_selections_note'], 1);
+ tr($lang_catmanage['row_selections']."*", 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)."
".$lang_catmanage['text_selections_note'], 1);
}
elseif ($type=='category')
{