mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 18:20:31 -05:00
(Update) Cache Queries
This commit is contained in:
@@ -123,11 +123,7 @@ class AnnounceController extends Controller
|
||||
}
|
||||
|
||||
// Check Passkey Against Cache or Users Table
|
||||
if (Cache::has("user.{$passkey}")) {
|
||||
$user = Cache::get("user.{$passkey}");
|
||||
} else {
|
||||
$user = User::where('passkey', '=', $passkey)->first();
|
||||
}
|
||||
$user = Cache::get("user.{$passkey}") ?? User::where('passkey', '=', $passkey)->first();
|
||||
|
||||
// If Passkey Doesn't Exist Return Error to Client
|
||||
if ($user === null) {
|
||||
@@ -210,14 +206,7 @@ class AnnounceController extends Controller
|
||||
}
|
||||
|
||||
// Check Info Hash Against Cache or Torrents Table
|
||||
if (Cache::has("torrent.{$info_hash}")) {
|
||||
$torrent = Cache::get("torrent.{$info_hash}");
|
||||
} else {
|
||||
$torrent = Torrent::select(['id', 'status', 'free', 'doubleup', 'times_completed', 'seeders', 'leechers'])
|
||||
->withAnyStatus()
|
||||
->where('info_hash', '=', $info_hash)
|
||||
->first();
|
||||
}
|
||||
$torrent = Cache::get("torrent.{$info_hash}") ?? Torrent::select(['id', 'status', 'free', 'doubleup', 'times_completed', 'seeders', 'leechers'])->withAnyStatus()->where('info_hash', '=', $info_hash)->first();
|
||||
|
||||
// If Torrent Doesnt Exsist Return Error to Client
|
||||
if ($torrent === null) {
|
||||
@@ -248,7 +237,7 @@ class AnnounceController extends Controller
|
||||
|
||||
// Pull Count On Users Peers Per Torrent For Rate Limiting
|
||||
$connections = Cache::remember("user_connections.{$torrent->id}", 1800, function () use ($torrent, $user) {
|
||||
return Peer::where('torrent_id', '=', $torrent->id)->where('user_id', '=', $user->id)->count();
|
||||
return Peer::where('torrent_id', '=', $torrent->id)->where('user_id', '=', $user->id)->count();
|
||||
});
|
||||
|
||||
// If Users Peer Count On A Single Torrent Is Greater Than X Return Error to Client
|
||||
|
||||
Reference in New Issue
Block a user