Commit 67dba768 authored by 王源's avatar 王源 🎧

添加缓存依赖和清除注解缓存方法

parent bc6ed1d7
......@@ -12,6 +12,7 @@
"require": {
"ext-json": "*",
"ext-redis": "*",
"hyperf/cache": "~1.1.0",
"hyperf/framework": "~1.1.0",
"hyperf/db-connection": "~1.1.0",
"hyperf/validation": "~1.1.0",
......
<?php
use Hyperf\Cache\Listener\DeleteListenerEvent;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext;
use Psr\EventDispatcher\EventDispatcherInterface;
/**
* 容器实例
......@@ -349,3 +352,21 @@ if (!function_exists('format_tree')) {
return $result;
}
}
if (!function_exists('flushAnnotationCache')) {
/**
* 刷新注解缓存,清楚注解缓存
* @param string $listener
* @param mixed $keys
* @return bool
*/
function flushAnnotationCache($listener, $keys)
{
$keys = is_array($keys) ? $keys : [$keys];
$dispatcher = ApplicationContext::getContainer()->get(EventDispatcherInterface::class);
foreach ($keys as $key) {
$dispatcher->dispatch(new DeleteListenerEvent($listener, [$key]));
}
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment