composer require predis/predis # laravel框架引入redis
composer update #更新composer
use Illuminate\Support\Facades\Redis; #控制器引入
public function redis(){
Redis::set('redis', 'hello,world!');
$test = Redis::get('redis');
dd($test);
$data = ['a'=>1,'b'=>2,'c'=>3,'d'=>4];
Redis::mset($data);
$test = Redis::mget(array_keys($data));
dd($test);
}
image.png
image.png
Redis::info();
Redis::select(4);#选择数据库
Redis::flushdb();# 清空数据库
image.png
image.png
网友评论