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

无法建立连接,因为目标计算机主动拒绝它。 [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.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路