mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
cache announce userInfo
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user