ehann / laravel-redis-store
为内置的Cache的RedisStore添加功能。
0.2.1
2017-07-01 19:46 UTC
Requires
- laravel/framework: ^5.3
Requires (Dev)
- mockery/mockery: ~0.9.4
- phpunit/phpunit: ^5.4
- predis/predis: ~1.0
This package is auto-updated.
Last update: 2024-09-14 14:29:43 UTC
README
为什么这很有用?
Laravel Cache自带的RedisStore默认不压缩字符串值。本包中的RedisStore会进行压缩。根据缓存项的大小和请求频率,缓存字符串值可以节省大量内存和/或网络带宽。
如何使用它?
安装包...
composer require ehann/laravel-redis-store
添加自定义缓存驱动,例如...
public function boot() { Cache::extend('ehann-redis', function ($app) { return Cache::repository(new \Ehann\Cache\RedisStore( $app['redis'], $app['config']['cache.prefix'], $app['config']['cache.stores.redis.connection'] )); }); }
将自定义驱动 ehann-redis 添加到config/cache.php中的redis store配置...
'stores' => [ 'redis' => [ 'driver' => 'ehann-redis', ], ],