dte49889 2017-07-19 12:01
浏览 328

无法建立连接,因为目标计算机主动拒绝它。 [tcp://127.0.0.1:6379] - codeigniter

my framework is codeigniter.

I want to use redis. I'm using predis.

https://packagist.org/packages/predis/predis

but I got this error:

An uncaught Exception was encountered

Type: Predis\Connection\ConnectionException

Message: No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]

Filename: C:\xampp\htdocs\****\application\vendor\predis\predis\src\Connection\AbstractConnection.php

Line Number: 155

my codes:

\Predis\Autoloader::register();
$redis = new \Predis\Client(array(
    "scheme" => "tcp",
    "host" => "127.0.0.1",
    "port" => 6379));

$client = new \Predis\Client();

$client->set('foo', 'bar');
$value = $client->get('foo');

echo $value;
return ;

my url to test my code is :

http://localhost:8085/...... 
  • 写回答

1条回答 默认 最新

  • dpqmu84646 2017-07-19 14:07
    关注

    1. Installing Redis

    Firstly you need to understand, that you've to install Redis as a serparate Service. You can't simply install a Redis Client like PRedis without a Redis Server.

    Since it was supported by the MSOpentechGroup there are several Windows Forks on Github out there, but unfortunately nobody maintains this forks anymore. You can see a conversation about this topic here.

    Anway, you find the download of the latest build here.

    2. Installing the client

    You can choose PRedis as a standalone PHP Library which is much slower compared to PHPRedis.

    The official Codeigniter documentation recommends PHPRedis because its caching driver depends on it. You can find more information here.

    Installing PHPRedis on Windows depends on your PHP Version. If you tell me your PHP Version i'm certainly willing to help you to find the correct driver.

    3. Using it with Codeigniter

    Since CI has an out of the box Driver for that you simple have to study this page here.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)