Consider having a default spec that can be overruled per cache name
marceloverdijk opened this issue · 4 comments
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
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:
- 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. - Users would need to keep this behavior in mind, because if someone sets
expireAfterWrite
to basic, but then wants to configureexpireAfterRead
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.
Merged
- 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?
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=....