JaC*_*hNo 2 caching redis laravel laravel-5
我正在尝试在 Laravel 中使用 Redis 进行缓存。
我已经在本地安装了 redis,并且我知道它正在工作,因为我能够运行水平队列和工作人员。
我在做时也得到回应
redis-cli PING
但是当我尝试这段代码时
$user = Cache::get('User:' .$Id , function ($Id) {
return User::where('id', '=', $Id)->firstOrFail();
});
Run Code Online (Sandbox Code Playgroud)
我收到错误
Redis connection [cache] not configured.
Run Code Online (Sandbox Code Playgroud)
我已将 .env 更改为具有以下条目
CACHE_DRIVER=redis
Run Code Online (Sandbox Code Playgroud)
小智 6
找到这个cache.php
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
Run Code Online (Sandbox Code Playgroud)
并将其更改为:
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
Run Code Online (Sandbox Code Playgroud)