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

API for application data caching #8140

Closed
emmanuelbernard opened this issue Mar 25, 2020 · 21 comments · Fixed by #8631
Closed

API for application data caching #8140

emmanuelbernard opened this issue Mar 25, 2020 · 21 comments · Fixed by #8631
Assignees
Labels
area/cache kind/enhancement New feature or request
Milestone

Comments

@emmanuelbernard
Copy link
Member

Offer a programmatic API for application data cache offering features above and beyond the annotation based ones.
Follow up of #3306

CC @karesti and @gwenneg

@nimo23
Copy link
Contributor

nimo23 commented Mar 25, 2020

One question:
Will quarkus use an already established caching provider (e.g. Infinispan) for its API? I think quarkus could indeed use, for example "Infinispan-embeeded" and provide its caching services (e.g. annotations and beyond) around this core.

@emmanuelbernard
Copy link
Member Author

emmanuelbernard commented Mar 25, 2020

Right now we only plan to use the existing cache implementation which uses caffeine.

If we go and support alternative providers like Infinispan or Hazelcast, we need to be very careful as these involve remote calls and the API must not assume locality cc @Sanne

@nimo23
Copy link
Contributor

nimo23 commented Mar 25, 2020

In my opinion, Quarkus Caching Layer should only use one cache provider internally. There is no need to support different caching providers (the same as there is no need to support different jpa providers).

Quarkus should stick with only one good caching provider and build on that. I think caching providers like infinispan are better suited for the Quarkus Caching Layer than to only use caffeine because I would like to see the following features for Quarkus Caching Layer:

  • off-heap-cache
  • hot and cold cache
  • caching data should not be limited to RAM but to storage (for inspiration see https://github.com/OpenHFT/Chronicle-Map or https://github.com/jankotek/mapdb or https://microstream.one/)
  • annotations for domain layer to enable and control the caching (maybe the JPA-annotations can be used and interpreted)
  • provide different transaction levels with support for strong cache consistency (SERIALIZABLE > REPEATABLE_READ > READ_COMMITTED > READ_UNCOMMITTED). Those transaction levels can be realized by using (programmatic JTA or @Transactional)

@nimo23
Copy link
Contributor

nimo23 commented Mar 25, 2020

as these involve remote calls and the API must not assume locality

Using caching providers in embeeded mode (e.g. infinispan-embeeded) can be run locally (and does not involve remote calls).

@Sanne
Copy link
Member

Sanne commented Mar 25, 2020

Sure: Infinispan is built on Caffeine providing such additional capabilities. We'll likely base such capabilities on the Infinispan code base, either directly or reimplementing bits and pieces with the help of the Infinispan team as best suited.

@emmanuelbernard
Copy link
Member Author

as these involve remote calls and the API must not assume locality

Using caching providers in embeeded mode (e.g. infinispan-embeeded) can be run locally (and does not involve remote calls).

I know but there is likely little value in swapping implementation in that case compared to the extra complexity of explaining how to configure stuff depending on the provider (more complex doc for example)

@emmanuelbernard emmanuelbernard moved this from Backlog to In Progress in General Roadmap (deprecated) May 13, 2020
@emmanuelbernard emmanuelbernard moved this from In Progress to 1.7 plan in General Roadmap (deprecated) May 13, 2020
@seseso
Copy link

seseso commented Jul 31, 2020

One thing I miss is an enabled flag on prpperties to enable or disable the extension. I have quite a long list of classes methods annotated and would like to easily enable/disable the extension, for instance, to compare performance. Unless I missed something in the docs, today this is not possible and would require the removal of all annotations from my code.

@gwenneg
Copy link
Member

gwenneg commented Jul 31, 2020

You are absolutely right @seseso, there is currently no way to disable the cache extension using a property, but I could easily take care of that missing flag. It looks like a build time property (meaning the flag could not be changed at runtime) would be enough, what do you think about that?

@seseso
Copy link

seseso commented Jul 31, 2020 via email

@gwenneg
Copy link
Member

gwenneg commented Jul 31, 2020

I created #11138 and #11139 to address your request @seseso.

@agentgonzo
Copy link

Should this be closed as done? https://quarkus.io/guides/cache

@mkouba
Copy link
Contributor

mkouba commented Nov 5, 2020

Should this be closed as done?

@agentgonzo I don't think so, this issue is about adding a "programmatic API", i.e. to be able to inject a Cache object representation and obtain a cached value for a given key.

@gwenneg
Copy link
Member

gwenneg commented Nov 5, 2020

@mkouba is right, this is still an ongoing subject.

@n1hility n1hility moved this from 1.7 done - Early August to Backlog in General Roadmap (deprecated) Jan 15, 2021
@vteferrer
Copy link

In my opinion, a programmatic way to access and operate the Cache is mandatory. The current operation is a good starting point but as a project grows, quickly emerge many situations where the minimalistic current API is not enough. I look forward to your next steps in this direction with great interest!

@gwenneg
Copy link
Member

gwenneg commented Jan 23, 2021

Thank you for your interest @vteferrer! There is actually an open PR (see #8631) with a proposal of programmatic caching API. It is purposely restricted to data access methods for now but there will certainly be more features in the future (like stats for example). Feel free to comment it if you have any idea or suggestion!

@vteferrer
Copy link

I´ve reviewed the open PR and I only miss a method to retrieve the keys associated with a Cache. This would be useful to to know what content has a Cache and find a particular item

@gwenneg
Copy link
Member

gwenneg commented Jan 25, 2021

Thanks for reviewing the PR @vteferrer! I pushed bdb47f4 to expose the cache keys in CaffeineCache.

@vteferrer
Copy link

The idea behind this change would be this, wouldn´t it?

    @Inject 
    @CacheName("my-cache")
    Cache cache;

    ...

    CaffeineCache caffeineCache = cache.asSpecializedCache(CaffeineCache.class);
    Set<Object> cachedKeys = caffeineCache.keySet();
    ...

I think it´s great!

Thanks!

@gwenneg
Copy link
Member

gwenneg commented Jan 26, 2021

Yes, that's exactly the idea.

@ghost
Copy link

ghost commented Jul 14, 2021

any workaround available at the moment to retrieve the Caffeine cache stats, while we wait for the PR #8631 to be merged?

@cfontes
Copy link

cfontes commented Oct 16, 2021

We really need something like this, current cache is barelly useful at any complex scenarios.

@quarkus-bot quarkus-bot bot added this to the 2.6 - main milestone Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cache kind/enhancement New feature or request
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

9 participants