@staticmethod
def __call__(_decoratee: Optional[Decoratee]=None, *, db_path: Optional[Path]=None, duration: Optional[Union[(int, float, timedelta)]]=None, keygen: Optional[Keygen]=None, pickler: Optional[Pickler]=None, size: Optional[int]=None) -> Union[Decoratee]:
    if (_decoratee is None):
        return partial(memoize, db_path=db_path, duration=duration, keygen=keygen, pickler=pickler, size=size)
    if inspect.isclass(_decoratee):
        assert (db_path is None), 'Class memoization not allowed with db.'

        class WrappedMeta(type(_decoratee)):

            @memoize(duration=duration, size=size)
            def __call__(cls, *args, **kwargs):
                return super().__call__(*args, **kwargs)

        class Wrapped(_decoratee, metaclass=WrappedMeta):
            pass
        return type(_decoratee.__name__, (Wrapped,), {'__doc__': _decoratee.__doc__})
    db = (connect(f'{db_path}') if (db_path is not None) else None)
    duration = (timedelta(seconds=duration) if isinstance(duration, (int, float)) else duration)
    assert ((duration is None) or (duration.total_seconds() > 0))
    pickler = (pickle if (pickler is None) else pickler)
    assert ((size is None) or (size > 0))
    fn = _decoratee
    default_kwargs: Mapping[(str, Any)] = {k: v.default for (k, v) in inspect.signature(fn).parameters.items()}
    if inspect.iscoroutinefunction(_decoratee):
        decorator_cls = _AsyncMemoize
    else:
        decorator_cls = _SyncMemoize
    decorator = decorator_cls(db=db, default_kwargs=default_kwargs, duration=duration, fn=fn, keygen=keygen, pickler=pickler, size=size).get_decorator()
    _Memoize._all_decorators.add(decorator)
    return wraps(_decoratee)(decorator)
@staticmethod
def __call__(_decoratee: Optional[Decoratee]=None, *, db_path: Optional[Path]=None, duration: Optional[Union[(int, float, timedelta)]]=None, keygen: Optional[Keygen]=None, pickler: Optional[Pickler]=None, size: Optional[int]=None) -> Union[Decoratee]:
    if (_decoratee is None):
        return partial(memoize, db_path=db_path, duration=duration, keygen=keygen, pickler=pickler, size=size)
    if inspect.isclass(_decoratee):
        assert (db_path is None), 'Class memoization not allowed with db.'

        class WrappedMeta(type(_decoratee)):

            @memoize(duration=duration, size=size)
            def __call__(cls, *args, **kwargs):
                return super().__call__(*args, **kwargs)

        class Wrapped(_decoratee, metaclass=WrappedMeta):
            pass
        return type(_decoratee.__name__, (Wrapped,), {'__doc__': _decoratee.__doc__})
    db = (connect(f'{db_path}') if (db_path is not None) else None)
    duration = (timedelta(seconds=duration) if isinstance(duration, (int, float)) else duration)
    assert ((duration is None) or (duration.total_seconds() > 0))
    pickler = (pickle if (pickler is None) else pickler)
    assert ((size is None) or (size > 0))
    fn = _decoratee
    default_kwargs: Mapping[(str, Any)] = {k: v.default for (k, v) in inspect.signature(fn).parameters.items()}
    if inspect.iscoroutinefunction(_decoratee):
        decorator_cls = _AsyncMemoize
    else:
        decorator_cls = _SyncMemoize
    decorator = decorator_cls(db=db, default_kwargs=default_kwargs, duration=duration, fn=fn, keygen=keygen, pickler=pickler, size=size).get_decorator()
    _Memoize._all_decorators.add(decorator)
    return wraps(_decoratee)(decorator)