1. 程式人生 > >【thinkphp5操作redis系列教程】雜湊型別之hMset

【thinkphp5操作redis系列教程】雜湊型別之hMset

<?php
namespace app\index\controller;
use Redis;
class Index
{
    public function index()
    {
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $redis->flushAll();

        /**
         * redis hash是一個string型別的field和value對映表,特別適用於儲存物件
         */
        // 批量填充HASH表
        $redis->hMset('h',array('name'=>'rocky','age'=>27));

        $res = $redis->hGetAll('h');
        var_dump($res);
        /**
         *
         */



    }




}