hset(self::_name($sender), self::_key($receive, $sender), serialize($message)); } /** * 获取好友之间或群聊中发送的最后一条消息缓存 * * @param int $receive 接收者 * @param int $sender 发送者(注:若聊天消息类型为群聊消息 $sender 应设置为0) * @return mixed */ public static function get(int $receive, $sender = 0) { $data = redis()->hget(self::_name($sender), self::_key($receive, $sender)); return $data ? unserialize($data) : null; } }