Class Yiisoft\Yii\Debug\Api\Inspector\Controller\CacheController
| Inheritance | Yiisoft\ |
|---|
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $responseFactory | \ |
|
public function __construct(
private DataResponseFactoryInterface $responseFactory,
) {}
| public \ | ||
| $container | \ |
|
public function clear(
ContainerInterface $container,
): ResponseInterface {
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.' ,
);
}
$cache = $container->get(CacheInterface::class);
$result = $cache->clear();
return $this->responseFactory->createResponse([
'result' => $result,
]);
}
| public \ | ||
| $request | \ |
|
| $container | \ |
|
public function delete(
ServerRequestInterface $request,
ContainerInterface $container,
): ResponseInterface {
$params = $request->getQueryParams();
$key = $params['key'] ?? '';
if ($key === '') {
throw new RuntimeException('Cache key must not be empty.');
}
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.' ,
);
}
$cache = $container->get(CacheInterface::class);
if (!$cache->has($key)) {
throw new RuntimeException('Key does not exist in cache');
}
$result = $cache->delete($key);
return $this->responseFactory->createResponse([
'result' => $result,
]);
}
| public \ | ||
| $request | \ |
|
| $container | \ |
|
public function view(
ServerRequestInterface $request,
ContainerInterface $container,
): ResponseInterface {
$params = $request->getQueryParams();
$key = $params['key'] ?? '';
if ($key === '') {
throw new RuntimeException('Cache key must not be empty.');
}
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.' ,
);
}
$cache = $container->get(CacheInterface::class);
if (!$cache->has($key)) {
return $this->responseFactory->createResponse([
'error' => 'Key does not exist in cache',
], 404);
}
$result = $cache->get($key);
$response = VarDumper::create($result)->asPrimitives(255);
return $this->responseFactory->createResponse($response);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.