wilbur-yu / hyperf-options
数据库中的全局键值存储
3.0.0
2023-01-15 10:03 UTC
Requires
- php: >=7.4
- hyperf/cache: ^3.0
- hyperf/database: ^3.0
- hyperf/db-connection: ^3.0
- hyperf/di: ^3.0
- hyperf/event: ^3.0
- hyperf/http-server: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0.0
- mockery/mockery: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^5.0
- swow/swow: dev-develop
- symfony/var-dumper: ^5.1
README
该组件移植自 appstract/laravel-options,感谢 原作者 的开源作品
安装
composer require wilbur-yu/hyperf-options
php ./bin/hyperf.php vendor:publish wilbur-yu/hyperf-options
php ./bin/hyperf.php migarte
说明
<?php use WilburYu\HyperfOptions\OptionService; // 使用全局函数 options()->set('key', 'value', 'desc'); // 创建或更新 options()->get('key'); options()->exists('key'); options()->remove('key'); // 使用服务类 $options = make(OptionService::class); $options->set('key', 'value', 'desc'); $options->get('key'); $options->exists('key'); $options->remove('key');
得益于 hyperf
完善的组件生态,监听 Option
模型的 Deleted 和 Saved
事件,搭配 Cache 注解
,可以很容易地完成 option 键值对
的缓存生命周期的维护。