public function random() {
try {
$redis = \Yii::$app->get("redis");
$key = "AD_RANDOM_ID";
$data = [1,2,3];
//检查长度
$list = $redis->llen($key);
if($list == 0){
foreach($data as &$v){
//把值加进去,先进先出
$redis->rpush($key, $v);
}
}
// $list = $redis->lrange($key, 0, -1);
// var_dump($list);die;
$lpop = $redis->lpop($key);
return Functions::formatRestAPI(0,'',$lpop);
}catch (Exception $e) {
return Functions::formatRestAPI(1, $e->getMessage());
}
}```
08-08
3631
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-25
700
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-11
675
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-11
499
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-01