redis = new \Redis(); $this->redis->connect('127.0.0.1', 6379); $this->redis->auth('123456'); } public function setOfTime($key = '', $value = '') { if (empty($key)) { die; } $this->redis->set( $key , $value); $this->redis->expire($key,180); } public function get($key = '') { if (empty($key)) { die; } return $this->redis->get( $key ); } }