Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Yii2 Redis Laravel Package

yiisoft/yii2-redis

Yii2 Redis extension providing Redis connection plus Cache, Session, and Mutex handlers, and an ActiveRecord layer to store and query structured data in Redis using familiar Yii2 patterns. Requires Redis 2.6.12+ and PHP 7.4+ (best on PHP 8).

View on GitHub
Deep Wiki
Context7

Redis Cache、Session 和 ActiveRecord 的“Predis”

配置应用程序

使用此扩展时,需要在你的应用程序配置中配置 [[yii\redis\predis\PredisConnection]] 类:

Warning: yii\redis\predis\PredisConnection 类支持 redis-cluster 连接,但是不提供对 cachesession​​ActiveRecordmutex 组件接口的支持。

standalone

return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\predis\PredisConnection',
            'parameters' => 'tcp://redis:6379',
            'options' => [
                'parameters' => [
                    'password' => 'secret', // Or NULL
                    'database' => 0,
                    'persistent' => true,
                    'async_connect' => true,
                    'read_write_timeout' => 0.1,
                    'retry' => new \Predis\Retry\Retry(new \Predis\Retry\Strategy\ExponentialBackoff(1000, 10000), 3), // Base and cap configuration in microseconds and number of retries
                ],
            ],
        ],
    ]
];

sentinel

return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\predis\PredisConnection',
            'parameters' => [
                'tcp://redis-node-1:26379',
                'tcp://redis-node-2:26379',
                'tcp://redis-node-3:26379',
            ],
            'options' => [
                'parameters' => [
                    'password' => 'secret', // Or NULL
                    'database' => 0,
                    'persistent' => true,
                    'async_connect' => true,
                    'read_write_timeout' => 0.1,
                    'retry' => new \Predis\Retry\Retry(new \Predis\Retry\Strategy\ExponentialBackoff(1000, 10000), 3), // Base and cap configuration in microseconds and number of retries
                ],
            ],
        ],
    ]
];

有关连接配置和选项的更多信息,请参阅 predis 文档。

这通过“redis”应用程序组件提供了对redis存储的基本访问:

Yii::$app->redis->set('mykey', 'some value');
echo Yii::$app->redis->get('mykey');

附加主题

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui