Commit 67dba768 authored by 王源's avatar 王源
Browse files

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

parent bc6ed1d7
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@
  "require": {
  "require": {
    "ext-json": "*",
    "ext-json": "*",
    "ext-redis": "*",
    "ext-redis": "*",
    "hyperf/cache": "~1.1.0",
    "hyperf/framework": "~1.1.0",
    "hyperf/framework": "~1.1.0",
    "hyperf/db-connection": "~1.1.0",
    "hyperf/db-connection": "~1.1.0",
    "hyperf/validation": "~1.1.0",
    "hyperf/validation": "~1.1.0",
+21 −0
Original line number Original line Diff line number Diff line
<?php
<?php


use Hyperf\Cache\Listener\DeleteListenerEvent;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Redis\Redis;
use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\ApplicationContext;
use Psr\EventDispatcher\EventDispatcherInterface;



/**
/**
 * 容器实例
 * 容器实例
@@ -349,3 +352,21 @@ if (!function_exists('format_tree')) {
        return $result;
        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;
    }
}