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

Cache programmatic API - invalidate entries whose keys match a predicate #30316

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

mkouba
Copy link
Contributor

@mkouba mkouba commented Jan 11, 2023

Currently, you would need to make use of CaffeineCache, then iterate over the key set and finally remove an entry if it matches a predicate/condition.

@mkouba mkouba requested review from gwenneg and gastaldi and removed request for gwenneg January 11, 2023 16:54
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 11, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Copy link
Member

@gwenneg gwenneg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement, thanks! This could use a new section in the cache doc.

LGTM

@mkouba
Copy link
Contributor Author

mkouba commented Jan 12, 2023

This could use a new section in the cache doc.

Yes, the Caching using the programmatic API could describe all io.quarkus.cache.Cache methods.

@mkouba mkouba merged commit f8f7c49 into quarkusio:main Jan 12, 2023
@quarkus-bot quarkus-bot bot added this to the 2.17 - main milestone Jan 12, 2023
@karesti
Copy link
Member

karesti commented Apr 4, 2024

@mkouba @gwenneg while I understand the motivation behind this method, for caching servers such as Redis or Infinispan looks like a dangerous idea to me (all the keys need to be read, apply the predicate and then send remove operations). I would like us to consider the idea of deprecating this method in the SPI

@karesti
Copy link
Member

karesti commented Apr 4, 2024

@cescoffier @geoand

@mkouba
Copy link
Contributor Author

mkouba commented Apr 4, 2024

@mkouba @gwenneg while I understand the motivation behind this method, for caching servers such as Redis or Infinispan looks like a dangerous idea to me (all the keys need to be read, apply the predicate and then send remove operations). I would like us to consider the idea of deprecating this method in the SPI

Hm, I don't think we should deprecate the method but instead throw an UnsupportedOperationException in Redis or Infinispan impls and add a note to the method javadoc. It's perfectly valid for inmemory impls such as Caffeine (which was BTW the only impl we had at the time the method was added ;-).

@karesti
Copy link
Member

karesti commented Apr 4, 2024

@mkouba sounds like the method was promoted because we had it in the library implementation we were using. I believe this method does not belong in a Caching SPI, but this is not my call

@mkouba
Copy link
Contributor Author

mkouba commented Apr 4, 2024

@mkouba sounds like the method was promoted because we had it in the library implementation we were using. I believe this method does not belong in a Caching SPI, but this is not my call

Well, that depends on how the cache is used. And it's actually not part of an SPI but a part of public user-facing API.

@karesti
Copy link
Member

karesti commented Apr 4, 2024

@mkouba looks like if it is also part of an SPI now, since we need to implement the interface to be used by the interceptors and chose a different cache provider

@karesti
Copy link
Member

karesti commented Apr 4, 2024

but as I said earlier, it's not my call :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants