mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-10-12 10:09:58 +00:00
Added a new middlware to properly handle per-request in-memory caching within the app.
31 lines
775 B
PHP
31 lines
775 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
use BookStack\View\ViewBlockManager;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Custom middleware to clear any local caches in the app which are created on a
|
|
* per-request basis. While this can be somewhat redundant in the normal PHP request
|
|
* lifecycle (since in memory caches are cleared on each request), this can be useful
|
|
* in testing and to prepare for future long-serving PHP runtimes.
|
|
*/
|
|
class ClearPerRequestCaches
|
|
{
|
|
public function __construct(
|
|
protected ViewBlockManager $viewBlockManager,
|
|
) {
|
|
}
|
|
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
$response = $next($request);
|
|
|
|
$this->viewBlockManager->clearLocalCache();
|
|
|
|
return $response;
|
|
}
|
|
}
|