-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Introduce cache injection and NoOpCache #13296
Conversation
a52669d
to
eef3439
Compare
Here are a few code examples to help validating the programmatic caching API elements from this PR:
|
9775531
to
35212e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added one small question.
*/ | ||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ FIELD, METHOD, PARAMETER }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You allow it for methods here but you don't check the method case in the processor. Is it normal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! It is allowed on methods because of CacheProducer
but I should add a check in CacheProcessor
to forbid the annotation on any other method than the one from the producer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the following changes:
- rebase on master to fix conflicts
- new check in
CacheProcessor
:@CacheName
is now only allowed on methods fromio.quarkus.cache.runtime.CacheProducer
- injection tests coverage improvement
Despite the targets of @CacheName
and the new check, it is possible to inject a cache using that annotation at all CDI usual injections points: fields, constructors parameters and methods parameters. These are all tested in this PR.
b3b6e0f
to
3328885
Compare
3328885
to
ddd8382
Compare
This PR lays some groundwork for the programmatic caching API (#8140). The vast majority of the changes here come from #8631 and has been discussed there already. I recently added
NoOpCache
which hasn't been reviewed though.So why create a new PR instead of keeping all this in #8631? For two reasons:
@CacheName
,Cache
andCacheManager
. I didn't put in this PR any of the API methods from Introduce programmatic caching API #8631 related to cached data (data retrieval or invalidation) since it was still being discussed. That's why theCache
interface is empty for now. @phillip-kruger will probably be the first one to add a method in this interface.This PR does not change anything in terms of behaviour for the annotations caching API when the extension is enabled. When it is disabled, the only change is the introduction of
NoOpCache
. The old way to disable the extension at build time wasn't compatible with the programmatic API, hence this new type of cache.This PR does not contain any change to the doc, that's intentional. I don't think we should document the programmatic API or the ability to inject a cache before there is at least one method in the
Cache
interface.I think this can be merged even if #8631 is still a WIP with a few open discussions as long as
@CacheName
,Cache
andCacheManager
are accepted as new members of the undocumented caching API (it seemed OK in #8631).