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
fix comment about the cache size and clarify configuration #335
Conversation
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.
Thanks for the PR, this is good stuff. I've added a couple of comments.
// Create a cache using infinite heap. A real application will want to use a more fine-grained configuration, | ||
// possibly using an implementation-dependent API | ||
// Enable statistics via the JCache programmatic configuration API. | ||
// The actual default size limit of the cache is implementation dependent and cannot be modified |
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 am not sure that's a valid alternative now you've removed the previous content. The intent of the original description was to mention that this was configuring a cache in-memory.
I agree the "infinite heap" part is irrelevant. At the time I meant to focus on the fact that using EhCache's specific API allows you to restrict the size in heap and various other options.
Can you please rephrase the description to focus on the original intent (that this configuration does not configure any sort of persistence for the cache).
// Enable statistics via the JCache programmatic configuration API. | ||
// The actual default size limit of the cache is implementation dependent and cannot be modified | ||
// via the standard JCache API. To set more configuration parameters check out the configuration | ||
// capabilities of the used caching implementation. |
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.
That and the (yet limited) standard API.
@snicoll, from the PR annotation:
That was your intent and this is in fact what is happening when you use EHCache (or Caffeine, or cache2k) without further configuration. But that intent is not and cannot be reflected in the configuration. The configuration here is generic to any JCache, which may be in heap, off heap or persistent. The comments and implications must therefor make sense for every JCache implementation.
That's correct, but it does not configure an in heap cache as well ;) I thought about mentioning that this yields an in memory cache together with EHCache dependency when no additional configuration is present, but explaining EHCache semantics in a generic JCache configuration file feels very weird. IMHO, it must be crisp and fit for every JCache. Thoughts? |
Yeah I agree. So perhaps we can focus the description on the statistics part then and mention that additional configuration options are available in this API and the JSR-107 implementation API ? |
Preparing a updated PR which will be actually not so crisp any more but explain all the implications in it. |
Cool, please push force on your existing branch to update this PR. |
Sure thing! |
e129076
to
8914865
Compare
… Spring and JCache
8914865
to
ea4fe8d
Compare
@snicoll: I did push a very much extended version yesterday. It's quite detailed now, and the documentation is more than the code. But I think that's how an example should look like ;) I plan to walk through the other examples and the documentation and propose some updates as well. |
Sorry but I disagree. That's very useful information for sure but I consider it overwhelming considering what that class does. It's not really the purpose of petclinic to explain how JCache works or some (rather advanced) concepts like what happens if a persistent cache is used. If you have a couple of links that provides more information I am happy to revisit the PR and use those links instead. Thoughts? |
Fair point. The stuff is important to know in the context, but this is not the place to do it in that detail.
The JCache Spec is a PDF which is not directly linkable (licensing....). Let's keep the PR dangling. Maybe a few sentences make sense to add in the Spring documentation itself, which is, BTW, a great introduction to all sorts of programming concepts. Then we link there.
Studying the Spring code, I think the best would be to remove the need of
This would make the whole class redundant. I think it would be great to be able to use the JCache caches as catch all as well. Of course, now there are the backwards compatibility issues to consider.... |
We've had that discussion before and I can't find back the thread but creating the caches on the fly is not happening. We have to fail when a cache is not present so that users know they have to do something. And creating something with a default config doesn't sound a sane choice to me. This thread is starting to expand to various topics and I'd like it to be focused. I am happy to review a PR to improve the Spring Framework documentation as long as it stays focused on what we do. |
Thanks for the explanation and sorry for veering off. Maybe the typical "warmup phase". Since this got too lengthy, I am closing this PR for now and will do a fresh one, once I have the time and gained more oversight. |
No worries. Do you mind if I take bits and pieces of your PR to improve that class. It certainly would be better than the current situation! |
Maybe that's the faster option. You could also accept the PR and then strip it as you like. I didn't mean to do a hostile take over of this class ;) |
* pr/335: Polish "Clarify cache configuration" Clarify cache configuration
Thanks a lot @cruftex ! I am happy to continue the discussion on the Spring Framework's tracker for further ideas to improve the doc. |
The comment
Create a cache using infinite heap.
is wrong.The JCache standard only requires a cache to store at least "some" values to pass the TCK. It is not required to be
heap
orinfinite
. cache2k limits to 2000 entries by default and passes the TCK.