[Cache] Programmatically manage the cache
Is your feature request related to a problem? Please describe. Currently it seems rather hard to remove or warmup the cache in controllers for example.
Describe the solution you'd like
I would like to have a Service that would mimmic the functionnality on the liip:imagine:cache:remove and liip:imagine:cache:resolve.
Describe alternatives you've considered Not doing this leads to either:
- Call the command from within the application, but this is rather verbose (https://symfony.com/doc/current/console/command_in_controller.html)
- Duplicate the functionality that would find the correct filters (
resolveInputFiltersAndPaths) andbustCache(orwarmUpCache) on each of them
Additional context ~
yeah, i agree that a reusable service is best for these kind of things. for the remove command, i am a bit confused as CacheManager::remove already accepts null for the filters and in that case does all filters. so i am not sure why the command is not more straightforward.
for the warmup, i think FilterService should get a new convenience method that takes a list of images and optionally a list of filters (defaulting to all filters if not provided) and do what the ResolveCacheCommand currently does. runCacheImageResolvecontains quite a bit of io as well. if we want to keep that, we'd need to be able to pass a callback function to the FilterService method that is called with an argument for the true / false or the exception that can then do the logging.
i think all of that is possible without BC break, so we can do it in the 2.x branch if you want to.