gemini / cache
Some Features for Hyperf Cache
Installs: 1 270
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.3
- hyperf/cache: ^2.0
- hyperf/di: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- limingxinleo/happy-join-hyperf: ^1.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: >=7.0
- swoole/ide-helper: dev-master
- swow/swow: dev-develop
- symfony/var-dumper: ^5.1
README
composer require gemini/cache
支持使用 this 获取当前实例的成员变量
配置映射关系,修改 dependencies.php
<?php return [ Hyperf\Cache\Aspect\CacheableAspect::class => Gemini\Cache\Aspect\CacheableAspect::class, ];
修改代码
<?php 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
使用 MD5 格式化缓存 KEY
配置映射关系,修改 dependencies.php
<?php return [ Hyperf\Cache\AnnotationManager::class => Gemini\Cache\AnnotationManager::class ];
再使用 Cacheable
注解时,KEY
值便会被转化为 prefix:md5
的格式。