赞
踩
- laravel版本5.3.*
-
- laravel使用redis作为缓存
- config/cache.php文件设置
- -> 'default' => env('CACHE_DRIVER', 'redis')
- redis单机配置(config/database.php):
-
- 'redis' => [
- 'cluster' => true,
- 'options' => [
- 'cluster' => 'redis', //使用原生集群
- ],
- 'default1' => [
- 'host' => env('REDIS_CLUSTER_HOST1', '127.0.0.1'),
- 'password' => env('REDIS_CLUSTER_PASSWORD1', null),
- 'port' => env('REDIS_CLUSTER_PORT1', 7000),
- 'database' => 0,
- ],
- 'default2' => [
- 'host' => env('REDIS_CLUSTER_HOST2', '127.0.0.1'),
- 'password' => env('REDIS_CLUSTER_PASSWORD2', null),
- 'port' => env('REDIS_CLUSTER_PORT2', 7000),
- 'database' => 0,
- ],
- 'default3' => [
- 'host' => env('REDIS_CLUSTER_HOST3', '127.0.0.1'),
- 'password' => env('REDIS_CLUSTER_PASSWORD3', null),
- 'port' => env('REDIS_CLUSTER_PORT3', 7000),
- 'database' => 0,
- ],
- ...
- ],
- laravel中使用redis, 可以继续框架自带的Cache方法
- 例如:
- \Cache::has($key) 判断key是否存在
- \Cache::get($key) 获取key值
- \Cache::add($key, $val, 过期时间s); 添加
- .....
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。