<?php


namespace App\Cache\User;


use App\Libs\Utils;
use Illuminate\Support\Facades\Redis;

class UserCache
{
    /**
     * 获取用户信息
     * @param $uid
     * @return mixed
     */
    public static function getUserInfo($uid)
    {
        $cacheKey = Utils::getCacheKey('user.info', [$uid]);
        return Redis::hgetAll($cacheKey);
    }

    /**
     * @param $uid
     * @param $field
     * @return mixed
     */
    public static function getUserInfoByField($uid, $field)
    {
        $cacheKey = Utils::getCacheKey('user.info', [$uid]);
        return Redis::hmget($cacheKey, $field);
    }

    /**
     * 修改用户信息
     * @param $uid
     * @param $data
     * @return mixed
     */
    public static function setUserInfo($uid, $data)
    {
        $cacheKey = Utils::getCacheKey('user.info', [$uid]);
        return Redis::hmset($cacheKey, $data);
    }
}