Allen
- Allen 2021-01-04 已签到连续签到1天,获得了5个金钱
yii2-redis为什么不支持pipeline?
$redis->multi(\Redis::PIPELINE);
common 下的 config 文件夹内
main-local.php
文件内配置全部 redis:'redis' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'localhost', 'port' => 6379, 'database' => 0, //'password' => '', ],
项目内任何 php 文件调用 redis:
一、存储字符串$redis = Yii::$app->redis
$redis->exists($key);
=> 是否存在$redis->set($data);
=> 添加数据到redis$redis->expire($key, $expire);
=> 设置生存周期(秒)$redis->get($key);
=> 获取redis数据二、获取、存储hash数据
1、Yii::$app->redis->hget($key, $hashKey);
=> 获取redis hash数据
2、Yii::$app->redis->hset($key, $hashKey, $data);
=> 设置redis hash数据@Jeter 不想回复,就不回复,你这样不是在浪费别人的时间吗?
- Allen 赞了回答
common 下的 config 文件夹内
main-local.php
文件内配置全部 redis:'redis' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'localhost', 'port' => 6379, 'database' => 0, //'password' => '', ],
项目内任何 php 文件调用 redis:
一、存储字符串$redis = Yii::$app->redis
$redis->exists($key);
=> 是否存在$redis->set($data);
=> 添加数据到redis$redis->expire($key, $expire);
=> 设置生存周期(秒)$redis->get($key);
=> 获取redis数据二、获取、存储hash数据
1、Yii::$app->redis->hget($key, $hashKey);
=> 获取redis hash数据
2、Yii::$app->redis->hset($key, $hashKey, $data);
=> 设置redis hash数据