def finalize_memo(self, memo: _Memo, key: Union[(int, str)]) -> Any:
    if memo.memo_return_state.raised:
        raise memo.memo_return_state.value
    elif ((self.db is not None) and (self.memos[key] is memo)):
        value = self.pickler.dumps(memo.memo_return_state.value)
        self.db.execute(dedent(f'''
                    INSERT OR REPLACE INTO `{self.table_name}`
                    (k, t0, t, v)
                    VALUES
                    (?, ?, ?, ?)
                '''), (key, memo.t0, time(), value))
    return memo.memo_return_state.value
def finalize_memo(self, memo: _Memo, key: Union[(int, str)]) -> Any:
    if memo.memo_return_state.raised:
        raise memo.memo_return_state.value
    elif ((self.db is not None) and (self.memos[key] is memo)):
        value = self.pickler.dumps(memo.memo_return_state.value)
        self.db.execute(dedent(f'
                    INSERT OR REPLACE INTO `{self.table_name}`
                    (k, t0, t, v)
                    VALUES
                    (?, ?, ?, ?)
                '), (key, memo.t0, time(), value))
    return memo.memo_return_state.value