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

Consider having a default spec that can be overruled per cache name #43

Closed
marceloverdijk opened this issue Jan 21, 2020 · 4 comments
Closed

Comments

@marceloverdijk
Copy link

marceloverdijk commented Jan 21, 2020

I like to configure the caches via properties like:

coffee-boots.cache.spec.myCache1=maximumSize=100000,expireAfterWrite=1m
coffee-boots.cache.spec.myCache1=maximumSize=200000,expireAfterWrite=1m

For all caches I e.g. want expireAfterWrite=1m

It would be nice to be able to specify a default spec like:

coffee-boots.cache.default-spec=expireAfterWrite=1m

and then only overwrite the settings needed like:

coffee-boots.cache.spec.myCache1=maximumSize=100000
coffee-boots.cache.spec.myCache1=maximumSize=200000
@stepio
Copy link
Owner

stepio commented Jan 21, 2020

Hello @marceloverdijk ,

Thanks for your interest in my pet project, I'm happy that my idea is useful not only for me.

Your suggestion looks cool. Most probably it's won't be used widely, but who cares?
Also I like that this feature needs explicit enabling - so that people won't get affected unless they enable it themselves.

Also good point that you propose to name it coffee-boots.cache.default-spec, not coffee-boots.cache.spec.default. This way it will never conflict with some cache named default.

I see just 2 possible items to consider:

  1. I'd prefer calling it coffee-boots.cache.basic-spec, as I use Spring Boot's built-in configuration as default. So I'd like to highlight that it's something to be extended.
  2. Users would need to keep this behavior in mind, because if someone sets expireAfterWrite to basic, but then wants to configure expireAfterRead cache, he/she would get a nasty surprise from this basic configuration.

But still, this is definitely a cool feature to add - feel free to contribute, or I'll handle it myself within this or next week.

Cheers.

@stepio
Copy link
Owner

stepio commented Feb 9, 2020

Merged

@stepio stepio closed this as completed Feb 9, 2020
@q3769
Copy link

q3769 commented Aug 3, 2021

  1. I'd prefer calling it coffee-boots.cache.basic-spec, as I use Spring Boot's built-in configuration as default. So I'd like to highlight that it's something to be extended.

If the current implementation is already using Spring Boot's properties as default, then I do not understand what the original request is asking for. Why not use the spring boot's

spring.cache.cache-names=cache1,cache2
spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s

as the base/default, and then just add

coffee-boots.cache.spec.myCache=maximumSize=200000,expireAfterWrite=1m

on top of that to override the default? What am I missing here?

@q3769
Copy link

q3769 commented Aug 3, 2021

btw, I'd prefer to see the word "caffeine" to appear somewhere in the property name, just for clarity. e.g. coffee-boots.cache.caffeine.spec.myCache=....

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

No branches or pull requests

3 participants