<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def set_record(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None, state=None, data=None, bucket=None):
 """ Write record to storage :param bucket: :param chat: :param user: :param state: :param data: :return: """

        if data is None:
            data = {}
        if bucket is None:
            bucket = {}

        chat, user = self.check_address(chat=chat, user=user)
        addr = f"fsm:{chat}:{user}"

        record = {'state': state, 'data': data, 'bucket': bucket}

        conn = await self.redis()
        await conn.execute('SET', addr, json.dumps(record))