symfony-cmf/block-bundle

RFC: BlockVarnishCache default TTL configurable by parameter

gonzalovilaseca opened this issue · 4 comments

What do you think of having the default TTL of BlockVarnishCache configurable by parameter?
I need it for my current project, so if it sounds interesting I could do a PR.

dbu commented

you mean this? https://github.com/symfony-cmf/BlockBundle/blob/master/Cache/BlockVarnishCache.php#L117

absolutely would make sense to be configurable. you could change the default to null and if the value is null use the configured default ttl. you could use the DAY constant for the field, btw. https://github.com/sonata-project/cache/blob/master/lib/CacheElement.php#L55

i would use a setDefaultTtl method rather than adding yet more constructor arguments, as there are quite a lot already. then the DI can add a call to that method if the configuration value was set.

Yes exactly, that's what I meant.
Sure I was thinking of a setMethod, I'm looking further into this as it seems Sonata has hardcoded that value in several places, so not sure if changing it there would have any effect.

dbu commented

i think here is the right place, as its injected in the constructor of the sonata cache class that is created. sonata cache can't provide a default value there, the factory class here in the bundle can.

ping