Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel:如何正确配置缓存_Php_Laravel_Caching - Fatal编程技术网

Php Laravel:如何正确配置缓存

Php Laravel:如何正确配置缓存,php,laravel,caching,Php,Laravel,Caching,我想在我的laraver 6.3应用程序中使用缓存。我遵循了,但在所有步骤之后,我的记录都不会应用到缓存中 My config/cache.php “存储”=>[ “apc”=>[ “驱动程序”=>“apc”, ], “数组”=>[ “驱动程序”=>“数组”, ], “数据库”=>[ “驱动程序”=>“数据库”, '表'=>'缓存', “连接”=>null, ], “文件”=>[ “驱动程序”=>“文件”, 'path'=>存储路径('framework/cache/data'), ], “me

我想在我的laraver 6.3应用程序中使用缓存。我遵循了,但在所有步骤之后,我的记录都不会应用到缓存中

My config/cache.php

“存储”=>[
“apc”=>[
“驱动程序”=>“apc”,
],
“数组”=>[
“驱动程序”=>“数组”,
],
“数据库”=>[
“驱动程序”=>“数据库”,
'表'=>'缓存',
“连接”=>null,
],
“文件”=>[
“驱动程序”=>“文件”,
'path'=>存储路径('framework/cache/data'),
],
“memcached'=>[
“驱动程序”=>“memcached”,
'persistent_id'=>env('MEMCACHED_persistent_id'),
‘sasl’=>[
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
“选项”=>[
//Memcached::OPT_CONNECT_TIMEOUT=>2000,
],
“服务器”=>[
[
'host'=>env('MEMCACHED_host','127.0.0.1'),
'port'=>env('MEMCACHED_port',11211),
“重量”=>100,
],
],
],
“redis”=>[
“驱动程序”=>“redis”,
“连接”=>“缓存”,
],
“dynamodb”=>[
“驱动程序”=>“发电机B”,
'key'=>env('AWS\u ACCESS\u key\u ID'),
'secret'=>env('AWS\u secret\u ACCESS\u KEY'),
'region'=>env('AWS\u DEFAULT\u region','us-east-1'),
'table'=>env('DYNAMODB_CACHE_table','CACHE'),
'endpoint'=>env('DYNAMODB_endpoint'),
],
],
创建缓存表迁移

public function up()
{
Schema::create('cache',函数(Blueprint$表){
$table->string('key')->unique();
$table->mediumText('value');
$table->integer('expiration');
});
}
公共职能部门
{
Schema::dropIfExists('cache');
}
当我使用

公共函数cacheUserToken($userId){
$token=uniqid(base64_编码(Str::random(60));
$ExpectionTime=60;
Cache::put($userId、$token、$expectiontime);
}
我希望这样的记录会在缓存表中,但事实并非如此

在教程中说我需要安装memcached驱动程序,我在谷歌上搜索了如何安装,但得到的答案是它已经在laravel from box中了


绝对没有发生错误,只是不起作用。我错过了什么?

您在.env上设置了哪个缓存驱动程序file@DhavalPurohit在.env文件中,我有CACHE\u DRIVER=file,然后它会将所有缓存数据写入文件中。不在数据库中。@DhavalPurohit,我该怎么办?将其更改为数据库@aabdugaliyev