Skip to content

Cache, allow custom wrapper types other than java.util.Optional [SPR-16530] #21073

@spring-projects-issues

Description

@spring-projects-issues

Ken Schosinsky opened SPR-16530 and commented

Currently the caching annotations can only work with java.util.Optional. There's no support for other wrapper types (e.g. Vavr's Option/Try/Either/Lazy etc.).

I would like to be able to register custom return value unwrappers or something equivalent to the key property for the return value:

// Example with Vavr's Either
@CachePut(cacheNames = "myCache", condition = "#result.isRight()", result = "#result.getRight()")
Either<String, CacheData> myMethod(int id);

Greetings,
Ken


Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions