https://github.com/lingyintech/yii2-predis
yii2-predis
https://github.com/lingyintech/yii2-predis
predis yii2-extension
Last synced: 2 months ago
JSON representation
yii2-predis
- Host: GitHub
- URL: https://github.com/lingyintech/yii2-predis
- Owner: LingyinTech
- License: mit
- Created: 2018-04-01T14:17:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-01T09:32:10.000Z (over 7 years ago)
- Last Synced: 2025-02-09T23:18:46.843Z (over 1 year ago)
- Topics: predis, yii2-extension
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-predis
在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');
```