Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional caching with the new EL #572

Closed
graemerocher opened this issue Mar 25, 2023 · 3 comments · Fixed by #692
Closed

Add conditional caching with the new EL #572

graemerocher opened this issue Mar 25, 2023 · 3 comments · Fixed by #692
Assignees
Labels
type: enhancement New feature or request

Comments

@graemerocher
Copy link
Contributor

graemerocher commented Mar 25, 2023

See micronaut-projects/micronaut-core#8954

@graemerocher graemerocher added the type: enhancement New feature or request label Mar 25, 2023
@sdelamo
Copy link
Contributor

sdelamo commented Oct 12, 2023

@timyates lets explore this for Micronaut Framework 4.3.0

@timyates
Copy link
Member

@graemerocher @sdelamo Do you have thoughts on what would conditional caching with the new EL look like? I'm unsure as to how to progress 🤔

@graemerocher
Copy link
Contributor Author

Example:

@Cacheable(name="fruit", condition="#{name != 'banana')}")
Fruit getFruit(String name) {

}

timyates added a commit that referenced this issue Nov 15, 2023
This adds a conditional field to `@Cacheable`, `@CachePut` and `@CacheInvalidate`.

Whenever the cache interceptor is invoked via a method annotated with one of these,
the conditional is evaluated to a boolean as to whether caching should be performed.

As this would slow down existing apps, or those not using conditional, we check to
see if the annotations contain a conditional, and if not the additional processing is
shortcircuited to go back to the old behavior.

Closes #572
sdelamo pushed a commit that referenced this issue Nov 20, 2023
This adds a conditional field to `@Cacheable`, `@CachePut` and `@CacheInvalidate`.

Whenever the cache interceptor is invoked via a method annotated with one of these,
the conditional is evaluated to a boolean as to whether caching should be performed.

As this would slow down existing apps, or those not using conditional, we check to
see if the annotations contain a conditional, and if not the additional processing is
shortcircuited to go back to the old behavior.

Closes #572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants