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

fix comment about the cache size and clarify configuration #335

Closed
wants to merge 1 commit into from

Conversation

cruftex
Copy link
Contributor

@cruftex cruftex commented Jul 12, 2018

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 or infinite. cache2k limits to 2000 entries by default and passes the TCK.

Copy link
Member

@snicoll snicoll left a 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
Copy link
Member

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.
Copy link
Member

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.

@cruftex
Copy link
Contributor Author

cruftex commented Jul 12, 2018

@snicoll, from the PR annotation:

The intent of the original description was to mention that this was configuring a cache in-memory.

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.

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).

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?

@snicoll
Copy link
Member

snicoll commented Jul 12, 2018

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 ?

@cruftex
Copy link
Contributor Author

cruftex commented Jul 12, 2018

Preparing a updated PR which will be actually not so crisp any more but explain all the implications in it.

@snicoll
Copy link
Member

snicoll commented Jul 12, 2018

Cool, please push force on your existing branch to update this PR.

@cruftex
Copy link
Contributor Author

cruftex commented Jul 12, 2018

Sure thing!

@cruftex
Copy link
Contributor Author

cruftex commented Jul 13, 2018

@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.
Probably, some parts of what I have written here now, make sense in the documentation as well, and/or, the code example should have links to the relevant documentation sections and vice versa.

@snicoll
Copy link
Member

snicoll commented Jul 13, 2018

It's quite detailed now, and the documentation is more than the code. But I think that's how an example should look like ;)

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?

@cruftex
Copy link
Contributor Author

cruftex commented Jul 13, 2018

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.

Fair point. The stuff is important to know in the context, but this is not the place to do it in that detail.

If you have a couple of links that provides more information I am happy to revisit the PR and use those links instead.

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.

Thoughts?

Studying the Spring code, I think the best would be to remove the need of createCache at all and make it default in the Spring JCacheManager. Like so:

	@Override
	protected Cache getMissingCache(String name) {
		CacheManager cacheManager = getCacheManager();
		javax.cache.Cache<Object, Object> jcache = 
                   cacheManager.createCache(name, new MutableCacheConfiguration());
		return new JCacheCache(jcache, isAllowNullValues());
	}

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....

@snicoll
Copy link
Member

snicoll commented Jul 13, 2018

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.

@cruftex
Copy link
Contributor Author

cruftex commented Jul 13, 2018

This thread is starting to expand to various topics and I'd like it to be focused.

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.

@cruftex cruftex closed this Jul 13, 2018
@snicoll
Copy link
Member

snicoll commented Jul 13, 2018

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!

@cruftex
Copy link
Contributor Author

cruftex commented Jul 13, 2018

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 ;)

@snicoll snicoll reopened this Jul 13, 2018
@snicoll snicoll self-assigned this Jul 13, 2018
snicoll pushed a commit that referenced this pull request Jul 13, 2018
@snicoll snicoll closed this in 893a18f Jul 13, 2018
snicoll added a commit that referenced this pull request Jul 13, 2018
* pr/335:
  Polish "Clarify cache configuration"
  Clarify cache configuration
@snicoll
Copy link
Member

snicoll commented Jul 13, 2018

Thanks a lot @cruftex ! I am happy to continue the discussion on the Spring Framework's tracker for further ideas to improve the doc.

arey added a commit to spring-petclinic/spring-petclinic-kotlin that referenced this pull request Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants