Use the cache tags correctly.
This commit is contained in:
parent
cec5499ada
commit
ae6b0f5c5e
|
@ -366,7 +366,7 @@ class NodesController extends Controller
|
||||||
$node = Models\Node::findOrFail($id);
|
$node = Models\Node::findOrFail($id);
|
||||||
|
|
||||||
$token = str_random(32);
|
$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]);
|
return response()->json(['token' => $token]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ActionController extends Controller
|
||||||
*/
|
*/
|
||||||
public function authenticateDownload(Request $request)
|
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)) {
|
if (is_null($download)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
@ -81,7 +81,7 @@ class ActionController extends Controller
|
||||||
$server->installed = ($status === 'installed') ? 1 : 2;
|
$server->installed = ($status === 'installed') ? 1 : 2;
|
||||||
$server->save();
|
$server->save();
|
||||||
|
|
||||||
return response('', 204);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ class ActionController extends Controller
|
||||||
*/
|
*/
|
||||||
public function configuration(Request $request, $token)
|
public function configuration(Request $request, $token)
|
||||||
{
|
{
|
||||||
$nodeId = Cache::pull('NodeConfiguration:' . $token);
|
$nodeId = Cache::tags(['Node:Configuration'])->pull($token);
|
||||||
if (is_null($nodeId)) {
|
if (is_null($nodeId)) {
|
||||||
return response()->json(['error' => 'token_invalid'], 403);
|
return response()->json(['error' => 'token_invalid'], 403);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,10 @@ class ServerController extends Controller
|
||||||
$this->authorize('download-files', $server);
|
$this->authorize('download-files', $server);
|
||||||
|
|
||||||
$token = str_random(40);
|
$token = str_random(40);
|
||||||
Cache::tags(['Downloads', 'Downloads:Server:' . $server->uuid])->put('Download:' . $token, [
|
Cache::tags(['Server:Downloads'])->put($token, [
|
||||||
'server' => $server->uuid,
|
'server' => $server->uuid,
|
||||||
'path' => $file,
|
'path' => $file,
|
||||||
], 1);
|
], 5);
|
||||||
|
|
||||||
return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $token);
|
return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $token);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue