bootell/yii2-phpredis

Redis Cache, Session and ActiveRecord for the Yii2 Using PhpRedis

dev-master / 2.0.x-dev 2022-06-22 06:06 UTC

This package is auto-updated.

Last update: 2024-04-22 10:11:24 UTC


README

687474703a2f2f646f776e6c6f61642e72656469732e696f2f72656469732e706e67

Yii 2 Redis extension using PhpRedis


The original yiisoft/yii2-redis extension uses socket to communicate. It has performance issues in high concurrency: long response time, and Failed to read from socket error. Instead of using the socket, this extension uses the phpredis to connect to redis server, and all classes and methods has save input and output as the original extension.

Yii 原始的 yiisoft/yii2-redis 扩展使用 socket 进行通信,在高并发下有性能问题,响应时间较长,并且会出现 Failed to read from socket 错误。

本扩展在原有 yii2-redis 的基础上,将连接方式替换为使用 php 原生扩展 phpredis/phpredis,性能大幅提高的同时,保持与原有扩展相同的调用方法方式,支持 Cache/Session/ActiveRecord,仅需替换对应类即可。

安装

php composer.phar require --prefer-dist bootell/yii2-phpredis:"*"

配置

return [
    //....
    'components' => [
        'redis' => [
            'class' => bootell\Yii2\redis\Connection::class,
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];

说明

  • phpredis 不支持配置超时重试次数 retries,但可配置重试间隔 retry_interval