limingxinleo/swoft-aop-cacheable

Swoft 基于Aop缓存扩展

1.1.4 2018-11-03 10:25 UTC

This package is auto-updated.

Last update: 2021-08-29 01:54:50 UTC


README

Swoft 基于Aop缓存

Build Status

使用

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');