def get_memo(self, key: Union[(int, str)], insert: bool) -> Optional[_Memo]:
    try:
        memo = self.memos[key] = self.memos.pop(key)
        if ((self.duration is not None) and (memo.t0 < (time() - self.duration.total_seconds()))):
            self.expire_order.pop(key)
            raise ValueError('value expired')
    except (KeyError, ValueError):
        if (not insert):
            return None
        elif (self.duration is None):
            t0 = None
        else:
            t0 = time()
            self.expire_order[key] = ...
        memo = self.memos[key] = self.make_memo(t0=t0)
    return memo
def get_memo(self, key: Union[(int, str)], insert: bool) -> Optional[_Memo]:
    try:
        memo = self.memos[key] = self.memos.pop(key)
        if ((self.duration is not None) and (memo.t0 < (time() - self.duration.total_seconds()))):
            self.expire_order.pop(key)
            raise ValueError('value expired')
    except (KeyError, ValueError):
        if (not insert):
            return None
        elif (self.duration is None):
            t0 = None
        else:
            t0 = time()
            self.expire_order[key] = ...
        memo = self.memos[key] = self.make_memo(t0=t0)
    return memo