Skip to content

Memoize for a duration based on the memoized item #915

@scrocquesel

Description

@scrocquesel

Context

Following discussion at #909.

Right now, memoize can be configured to expire based on a BooleanSupplier. To invalidate memoized item based on its value, a solution is to used a shared AtomicBoolean with a throw/retry mechanism when the boolean become true. See #909 (reply in thread).

Another drawback is that failure cannot be skipped or memoized differently

Description

It would more convenient to be able to pass a BiFunction that takes the item and the failure and return a boolean to until().

Uni.createFrom().item(new AccessTokenResponse())
    .memoize().until((item, failure) -> failure != null || item.isExpired())

Additional details

Some shortcuts could help like

Uni.createFrom().item(new AccessTokenResponse())
    .memoize().notFailure().until(item -> item.isExpired())
    .memoize().notFailure().atLeast(item -> item.getExpiresIn())

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions