From ae6b0f5c5ed1ab9e79c367935f3a050433f6fe71 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 1 May 2017 14:52:14 -0400 Subject: [PATCH] Use the cache tags correctly. --- app/Http/Controllers/Admin/NodesController.php | 2 +- app/Http/Controllers/Daemon/ActionController.php | 6 +++--- app/Http/Controllers/Server/ServerController.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php index 8471c4bc5..f6fc7b194 100644 --- a/app/Http/Controllers/Admin/NodesController.php +++ b/app/Http/Controllers/Admin/NodesController.php @@ -366,7 +366,7 @@ class NodesController extends Controller $node = Models\Node::findOrFail($id); $token = str_random(32); - Cache::put('NodeConfiguration:' . $token, $node->id, 5); + Cache::tags(['Node:Configuration'])->put($token, $node->id, 5); return response()->json(['token' => $token]); } diff --git a/app/Http/Controllers/Daemon/ActionController.php b/app/Http/Controllers/Daemon/ActionController.php index c2d324b49..0a054218c 100644 --- a/app/Http/Controllers/Daemon/ActionController.php +++ b/app/Http/Controllers/Daemon/ActionController.php @@ -40,7 +40,7 @@ class ActionController extends Controller */ public function authenticateDownload(Request $request) { - $download = Cache::pull('Download:' . $request->input('token')); + $download = Cache::tags(['Server:Downloads'])->pull($request->input('token')); if (is_null($download)) { return response()->json([ @@ -81,7 +81,7 @@ class ActionController extends Controller $server->installed = ($status === 'installed') ? 1 : 2; $server->save(); - return response('', 204); + return response()->json([]); } /** @@ -93,7 +93,7 @@ class ActionController extends Controller */ public function configuration(Request $request, $token) { - $nodeId = Cache::pull('NodeConfiguration:' . $token); + $nodeId = Cache::tags(['Node:Configuration'])->pull($token); if (is_null($nodeId)) { return response()->json(['error' => 'token_invalid'], 403); } diff --git a/app/Http/Controllers/Server/ServerController.php b/app/Http/Controllers/Server/ServerController.php index 3bc1ea2ac..04066b7a3 100644 --- a/app/Http/Controllers/Server/ServerController.php +++ b/app/Http/Controllers/Server/ServerController.php @@ -202,10 +202,10 @@ class ServerController extends Controller $this->authorize('download-files', $server); $token = str_random(40); - Cache::tags(['Downloads', 'Downloads:Server:' . $server->uuid])->put('Download:' . $token, [ + Cache::tags(['Server:Downloads'])->put($token, [ 'server' => $server->uuid, 'path' => $file, - ], 1); + ], 5); return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $token); }