digitalnatives/craft3-illuminate-redis-adapter

基于 Illuminate redis 的 Redis 缓存,适用于 CraftCMS 3|4

1.4.0 2024-09-04 14:02 UTC

This package is auto-updated.

Last update: 2024-09-04 14:03:51 UTC


README

基于 Illuminate redis 的 Redis 缓存,适用于 CraftCMS 3

安装

您可以使用 composer 安装此包;

composer require digitalnatives/craft3-illuminate-redis-adapter

选择一个适配器

PHPredis(推荐)

为了最佳性能,我们推荐使用 ext-phpredis

配置

return [
    'components' => [
        'cache' => [
            'class' => DigitalNatives\Cache\Redis::class,
            'defaultDuration' => 86400,
            'connection' => 'phpredis',
            'config' => [
                'host' => getenv('REDIS_HOST'),
                'port' => (int)getenv('REDIS_PORT'),
                'database' => getenv('REDIS_DB'),
                'connectTimeout' => 60,
                'readTimeout' => 60,
                'serializer' => \Redis::SERIALIZER_NONE
            ],
        ],
    ],
];

predis

当安装 PHP 扩展不是一种选择时,predis 是一个非常不错的选择。

如果您还没有安装 predis,可以使用 composer 进行安装;

composer require predis/predis

配置

return [
    'components' => [
        'cache' => [
            'class' => DigitalNatives\Cache\Redis::class,
            'defaultDuration' => 86400,
            'connection' => 'predis',
            'params' => [
                'host' => getenv('REDIS_HOST'),
                'port' => (int)getenv('REDIS_PORT'),
            ],
            'options' => [
                ['profile' => '5.0']
            ]           
        ],
    ],
];