PHP code example of yangjisen / laravel-cache-provider
1. Go to this page and download the library: Download yangjisen/laravel-cache-provider library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yangjisen / laravel-cache-provider example snippets
'providers' => [
/*
* Package Service Providers...
*/
YangJiSen\CacheUserProvider\ServiceProvider::class,
]
return [
/*
|--------------------------------------------------------------------------
| 缓存的保存时间
|--------------------------------------------------------------------------
|
| 默认值(秒): 3600
| 注意: Laravel5.8以前缓存单位由为分钟, 此处需要自行修改时间
| @see https://laravel.com/docs/5.8/upgrade#cache-ttl-in-seconds
|
*/
'cache_ttl' => env('CACHE_USER_TTL', 3600),
/*
|--------------------------------------------------------------------------
| 缓存的保存方式
|--------------------------------------------------------------------------
|
| single: 所有的保存为一个缓存键值
| every: 按照单个用户进行缓存
|
*/
'cache_channel' => env('CACHE_USER_CHANNEL', 'every'),
/*
|--------------------------------------------------------------------------
| 渴望加载的关联模型
|--------------------------------------------------------------------------
|
| String: a,b,c
|
| 使用关联加载时,关联的数据仅在第一次查询时加载,缓存后不会自动进行更新,需要自行实现关联更新时删除缓存数据
|
| @param \Illuminate\Database\Eloquent\Model $user
| 调用删除方法: YangJiSen\CacheUserProvider\CacheForget::CacheForget($user);
|
*/
'model_with' => env('CACHE_USER_MODEL_WITH'),
];
'providers' => [
'users' => [
'driver' => 'cache',
'model' => App\User::class,
],
]
shell
php artisan vendor:publish --provider="YangJiSen\CacheUserProvider\ServiceProvider"