PHP code example of lujihong / hyperf-cache

1. Go to this page and download the library: Download lujihong/hyperf-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lujihong / hyperf-cache example snippets




return [
    Hyperf\Cache\Aspect\CacheableAspect::class => Lujihong\Cache\Aspect\CacheableAspect::class,
];



use Hyperf\Cache\Annotation\Cacheable;

class UserService
{
    public $id = 1;

    /**
     * @Cacheable(prefix="test", value="#{this.id}")
     */
    function getCache()
    {
        return uniqid();
    }
}

$res = (new UserService())->getCache(); // 生成的缓存 KEY 为 test:1




return [
    Hyperf\Cache\AnnotationManager::class => Lujihong\Cache\AnnotationManager::class
];