nasustop / hapi-cache
Installs: 1 586
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- hyperf/cache: ^3.0
- hyperf/contract: ^3.0
- hyperf/event: ~3.0.0
- hyperf/framework: ~3.0.0
- hyperf/redis: ^3.0
- nasustop/hapi-memcached: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2024-11-30 02:38:51 UTC
README
hyperf的cache扩展组件
安装
composer require nasustop/hapi-cache
基于hyperf2.2版本
composer require nasustop/hapi-cache:~2.2.0
使用说明
对Hyperf/Cache
做了功能扩展
- 增加
MemcachedDriver
- 增加指定
redis
和memcached
的pool
- 增加
memory
缓存类型,基于Swoole\Table
实现
配置文件
愿配置文件
<?php declare(strict_types=1); return [ 'default' => [ 'driver' => Hyperf\Cache\Driver\RedisDriver::class, 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, 'prefix' => 'c:', ], ];
增加扩展后的配置文件
<?php declare(strict_types=1); return [ 'default' => [ 'driver' => \Nasustop\HapiCache\RedisDriver::class, 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, 'prefix' => 'c:', 'pool' => 'default', ], 'memcached' => [ 'driver' => \Nasustop\HapiCache\MemcachedDriver::class, 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, 'prefix' => 'c:', 'pool' => 'default', ], 'memory' => [ 'driver' => \Nasustop\HapiCache\MemoryDriver::class, 'packer' => Hyperf\Utils\Packer\PhpSerializerPacker::class, 'size' => 10240, // 最大缓存行数 'memory_size' => 1024 * 1024 * 1024 * 2, // 最大占用内存 'row_size' => 4096, // 每个缓存的最大长度 'ttl' => 3600 * 24 * 365, // 默认缓存时间 'clean_size' => 500, // 超出最大缓存行数或最大占用内存时,删除旧数据的数量,小于等于0时全部删除 ], ];