lingyin/predis

There is no license information available for the latest version (v0.0.1) of this package.

yii2整合predis,支持哨兵、集群

v0.0.1 2018-04-22 16:14 UTC

This package is auto-updated.

Last update: 2024-04-29 03:57:02 UTC


README

在yii2 框架中使用 predis , 支持cluster,sentinel

安装

composer require lingyin/predis

配置

return [
    'components' =>
        'cache' => [
            'class' => \lingyin\predis\Cache::class,
            'keyPrefix' => 'lingyin-common:',
            'redis' => [
                'parameters' => [
                    [
                        'host' => '127.0.0.1',
                        'port' => 6380,
                    ],
                    [
                        'host' => '127.0.0.1',
                        'port' => 6381,
                    ],
                ],
                'options' => [
                    'replication' => 'sentinel',
                    'service' => 'sentinel-127.0.0.1-6380',
                    'parameters' => [
                        'password' => 'profileLogStash',
                        'database' => 4,
                    ]
                ],
            ]
        ]
    ]

使用

// set 
$result = Yii::$app->cache->set('test','test',600);  

// get
$value = Yii::$app->cache->get('test');