项目作者: limingxinleo

项目描述 :
基于Swoft Aop的缓存机制
高级语言: PHP
项目地址: git://github.com/limingxinleo/swoft-aop-cacheable.git
创建时间: 2018-07-24T02:08:15Z
项目社区:https://github.com/limingxinleo/swoft-aop-cacheable

开源协议:

下载


swoft-aop-cacheable

Swoft 基于Aop缓存

Build Status

使用

config/properties/app.php中增加对应的组件

  1. 'components' => [
  2. 'custom' => [
  3. 'Swoftx\\Aop\\Cacheable\\',
  4. ],
  5. ]

增加需要进入缓存切面的类

  1. <?php
  2. namespace SwoftTest\Testing\Bean;
  3. use Swoft\Bean\Annotation\Bean;
  4. use Swoftx\Aop\Cacheable\Annotation\Cacheable;
  5. /**
  6. * Class Demo
  7. * @Bean
  8. * @package SwoftTest\Testing\Bean
  9. */
  10. class Demo
  11. {
  12. /**
  13. *
  14. * @author limx
  15. * @Cacheable(key="output:{0}:{1}:{2}", ttl=36000)
  16. * @param $name
  17. * @return mixed
  18. */
  19. public function output($name, $sex = 1, $msg = 'hello world')
  20. {
  21. return $name;
  22. }
  23. }

调用

  1. <?php
  2. use SwoftTest\Testing\Bean\Demo;
  3. $bean = bean(Demo::class);
  4. $res = $bean->output('limx');