Use the cache tags correctly.

This commit is contained in:
Dane Everitt 2017-05-01 14:52:14 -04:00
parent cec5499ada
commit ae6b0f5c5e
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 6 additions and 6 deletions

View File

@ -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]);
}

View File

@ -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);
}

View File

@ -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);
}