limingxinleo / swoft-aop-cacheable
Swoft 基于Aop缓存扩展
Installs: 1 504
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- swoft/framework: ^1.0.24
- swoft/redis: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- swoft/swoole-ide-helper: dev-master
README
Swoft 基于Aop缓存
使用
config/properties/app.php中增加对应的组件
'components' => [
'custom' => [
'Swoftx\\Aop\\Cacheable\\',
],
]
增加需要进入缓存切面的类
<?php namespace SwoftTest\Testing\Bean; use Swoft\Bean\Annotation\Bean; use Swoftx\Aop\Cacheable\Annotation\Cacheable; /** * Class Demo * @Bean * @package SwoftTest\Testing\Bean */ class Demo { /** * * @author limx * @Cacheable(key="output:{0}:{1}:{2}", ttl=36000) * @param $name * @return mixed */ public function output($name, $sex = 1, $msg = 'hello world') { return $name; } }
调用
<?php use SwoftTest\Testing\Bean\Demo; $bean = bean(Demo::class); $res = $bean->output('limx');