I have installed redis with laravel by adding "predis/predis":"~1.0",

Then for testing i added the following code :

public function showRedis($id = 1)
   {
      $user = Redis::get('user:profile:'.$id);
      Xdd($user);
   } 

In app/config/database.php i have :

'redis' => [
        'cluster' => false,
        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

它抛出以下错误:No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]

我用virtualhost英镑做这个项目.

推荐答案

First make sure Redis is actually listening on that port by opening up powershell and typing netstat -aon | more (this command may need to be enabled in features or installed somehow). If it is listening then check your firewall settings. If if not listening then make sure Redis is started and is configured to listen on that port.

It looks like predis/predis is a client library only. See https://packagist.org/packages/predis/predis.

您需要安装Redis服务器,但Windows似乎不支持它.见http://redis.io/download.根据该页面上的信息,Redis here https://github.com/MSOpenTech/redis似乎有一个Win64端口.

If it still doesn't work after that then update your question with the new error you see.

Laravel相关问答推荐

Laravel-如何按第三表关系对数据进行分类

Laravel中如何动态更改路由链接?

如何在Laravel中创建自定义单项集合

Laravel:在 PHPUnit 的覆盖率报告中包含文件夹(如果在 app/ 文件夹之外)?

自从 Laravel 使用 Vite 更新后,我无法运行npm run dev

Laravel created_at 返回对象代替数据库中的日期格式?

Laravel:如何强制使用 HTTPS?

Laravel + SQLite = SQLSTATE[HY000]一般错误:8次try 写入只读数据库

Laravel 表 * 没有名为 * 的列

导航栏品牌中的 Laravel 动态页面标题

当表中不存在列时如何将 paginate() 与 having() 子句一起使用

在 Eloquent 中按自定义顺序对集合进行排序

控制器外部的 Laravel 访问请求对象

Laravel db 迁移 - renameColumn 错误 - 请求了未知的数据库类型枚举

是否可以将路由参数传递给 Laravel 中的控制器构造函数?

遍历 Laravel 控制器中的结果集

如果在 Laravel 5.1 中找不到路由,则显示 404 页面

Laravel or where

在 Laravel 中翻译特定语言

错误:找不到模块 'webpack/lib/rules/DescriptionDataMatcherRulePlugin' 需要堆栈: